SparkFun Forums 

Where electronics enthusiasts find answers.

User avatar
By bm16ton
#233173
Im gonna tell a story first fixes at bottom.
I have a Artemis nano and ATP and my cousin has those plus an Artemis DK. The DK is his favorite board, this is important to remember, the DK is his favorite. I wanted to do a quick project/test using an accelerometer so I asked him to bring it over. When he arrived I told him I wanted to use the accelerometer. He replied "It doesnt work" I said did you use the sparkfun lib? He said yes and then said he probly did it wrong...I said its hard to screw up hitting the upload button (yup he thought he made a mistake hes very new to this and has a l ot of faith in sparkfun) So I clicked compiile and sure enuff the mbed has same symbols for same device....Despite the getting started still saying to use the lib. I used sed and removed the number 12 from all instances of function names and then readded it to the filenames and incudes etc. And then it compiled...Thats sorta ok but heres where it gets just plain silly. I said well hit the upload button...He said that doesnt work.....What do you mean? It shows as a mass storage right? He says yes but it dont work...and he was right! Seriously!!!?? What the hell! So I spent the entire 2minutes required to make it work....the same 2 minutes Sparkfun was apparently not willing to spend. Did I mention you made my cousin feel inadequate and that it was his fault because he doesnt know any better and trusts Sparkfun, wonder how many other cousins had the same thing feeling from this. I realize big ports hardwork takes time...BUT THE UPLOAD! Simple fix? I realize you guys probly live in one of those cities where money has been replaced with hugs and random strangers give you back rubs on the street but here, where I live you mess with a mans cousin with great peril. So not finding my script for doing this exact thing I simply reused the stm32 script directions to follow;

because I like consistency at top of boards.txt add to
menu.loader=Uploader
menu.svl_baud=SparkFun Variable Loader Baud Rate
menu.asb_baud=Ambiq Secure Bootloader Baud Rate

the following line
menu.upload_method=Upload method

# Menu Options
menu.loader=Uploader
menu.svl_baud=SparkFun Variable Loader Baud Rate
menu.asb_baud=Ambiq Secure Bootloader Baud Rate
menu.upload_method=Upload method

the next section is for the DK add the following lines to the bottom of it

sfe_artemis_dk.menu.upload_method.MassStorage=Mass Storage
sfe_artemis_dk.menu.upload_method.MassStorage.upload.protocol=
sfe_artemis_dk.menu.upload_method.MassStorage.upload.tool=massStorageCopy

Now at the bottom of platform.txt is the upload script info add the following

# Upload to board via mass storage
tools.massStorageCopy.cmd=massStorageCopy.sh
tools.massStorageCopy.cmd.windows=massStorageCopy.bat
tools.massStorageCopy.path={runtime.platform.path}/win
tools.massStorageCopy.path.macosx={runtime.platform.path}/macosx
tools.massStorageCopy.path.linux={runtime.platform.path}/tools/uploaders/
tools.massStorageCopy.upload.params.verbose=
tools.massStorageCopy.upload.params.quiet=
tools.massStorageCopy.upload.pattern="{path}/{cmd}" {upload.verbose} -I "{build.path}/{build.project_name}.bin" -O "{node}"

NOTE I only use opensource OS's so this is for linux but steeling the upload script from stm should be easy enuff for the crazies who like having thier PC's owned by someone else IE microsoft
now create a file massStorageCopy.sh inside the folder tools/uploaders which is in the same folder as boards.txt and platform.txt with the following contents;

#!/bin/bash
set -o nounset # Treat unset variables as an error

# List
bin_filepath=
mountpoint_name=
mountpoint_path=

###############################################################################
## Help function
usage() {
echo "############################################################"
echo "##"
echo "## $(basename "$0") [-I <filepath>] [-O <mountpoint(s)> ]"
echo "##"
echo "## Options:"
echo "## -I: filepath binary to copy"
echo "## -O: mountpoint(s) destination name"
echo "## Could be a list (separated by','). Ex: \"NODE_1,NODE2,NODE_3\""
echo "## Note:"
echo "## -I and -O are optionals and kept for backward compatibility."
echo "############################################################"
exit 0
}

if [ $# -lt 2 ]; then
usage
exit 1
fi

# Parsing options
if [ "$1" == "-I" ]; then
shift 1
fi

bin_filepath=$1

if [ "$2" == "-O" ]; then
shift 1
fi
# Strip first and last ""
mountpoint_name="${2%\"}"
mountpoint_name="${mountpoint_name#\"}"

if [ -z "$bin_filepath" ]; then
echo "No binary file path provided!"
exit 1
fi
if [ -z "$mountpoint_name" ]; then
echo "No mountpoint name provided!"
exit 1
fi

if [ ! -f "$bin_filepath" ]; then
echo "$bin_filepath not found!"
exit 2
fi

# Add short node name
IFS=' ,\t' read -ra mnt_list <<< "$mountpoint_name"
for mnt in "${mnt_list[@]}"; do
if [[ "$mnt" == "NODE_"* ]]; then
mountpoint_name="${mountpoint_name},${mnt//E_/_}"
fi
done

# Search the mountpoint
IFS=' ,\t' read -ra mnt_list <<< "$mountpoint_name"
for mnt in "${mnt_list[@]}"; do
# mnt_path_list=(`cat /proc/mounts | cut -d' ' -f2 | sort -u | grep $mnt`)
mnt_path_list=($(df -Hl | grep -v "Mounted on" | rev | cut -d' ' -f1 | rev | sort -u | grep "$mnt"))
if [ ${#mnt_path_list[@]} -ne 0 ]; then
# Ensure to have exact match
for mnt_path in "${mnt_path_list[@]}"; do
mnt_name=$(echo "$mnt_path" | rev | cut -d'/' -f1 | rev)
if [ "$mnt_name" = "$mnt" ]; then
echo "Found '$mnt' at '$mnt_path'"
mountpoint_path=$mnt_path
break
fi
done
fi
done

if [ -z "$mountpoint_path" ] || [ ! -d "$mountpoint_path" ]; then
echo "$mountpoint_name not found."
echo "Please ensure the device is correctly connected and mounted."
exit 3
fi

# Copy the binary to the mountpoint
echo "Copying $bin_filepath to $mountpoint_path..."
cp "$bin_filepath" "$mountpoint_path"

exit $?

dont forget to chmod +x massStorageCopy.sh also make sure arduino is not running when editing its files some files are cached and over written of you do.

For ruffly a year ive been using the artemis boards on my arm64 (all I use these days) with no problems all thats needed is a toolchain. So the only reason I cant use the regular install method is because Sparkfun wont include a simple url in the boards package json. I mentioned this in the forums sum months ago and I still have a ridiculously complicated install/upgrade procedure to go thru because they havent added it...Now I realize they dont even support the gd upload button Im screwed on getting a url added to that file! Did I mention they messed with my cousin? Did that come up? And its still his favorite board. So once all this was done I said great we worked thru all the problems now lets hookup these neopixels I have to it....
 Topic permissions

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum