How to upload firmware from ambiq sdk to redboard through bootloader?

Hi,

I have got a sparkfun edge board and a redboard. i have tried the examples codes from ambiq sdk and sparkfun example tensorflow on edge board using the given python scripts and it was working fine.

Now i want to try the same examples from ambiq sdk(i2c, ble…) on the redboard but unable to upload the firmware using the sparkfun uart_wired_update_sparkfun.py i have also tried the ambiq wired update script but couldn’t update it. (As edge board and red board have different bootloaders)

i have also tried arduino to upload and it was working, so i have used artemis_svl.py script from the .arduino15 to program using the makefile but some port issues are coming.

${PROGRAMMER_SCRIPT} -b 115200 -f $(CONFIG)/main_nonsecure_wire.bin -v -t 0.50 $(SERIAL_PORT)

please have a look at the attached screenshot.

i think i have given proper permission for the USB and made sure not other terminal is using the port.

https://drive.google.com/open?id=1pqFfh … 6q3iF0Q8EV

I don’t have a jlink programmer so what is the proper way to program the redboard using bootloader?

its so dark out here … :expressionless:

I’m having a similar issue using artemis_svl to upload a simple “blink” example to the artemis nano board.

I cloned the repo located here:

https://github.com/schreinerman/Apollo3 … amples.git (fetch)

and successfully built the projectusing the supplied make file and arm-none-eabi compiler, however when I attempt to upload the code to the nano using artemis_svl, it appears to load correctly, but I cannot get the onboard LED to turn on no matter what I try. I attempted setting all the GPIO to output and then setting all pins high, but the light never came on. I suspect that the sparkfun bootloader is never loading my program in the first place… if that’s true, how should we be flashing the a binary created from a SDK example project? Can we flash non-arduino binaries to the device and still use the artemis bootloader?

sample build below:

yi@bigpaper ~/git/Apollo3Blue_SoftwareExamples/apollo3-stimer/example/make (master*) $ make bootload
Compiling C file: main.o
arm-none-eabi-gcc -D APOLLO3_1024=1 -D APOLLO3_1024=1 -g -ggdb -Os -Wall -fno-strict-aliasing -fno-strict-aliasing  -ffunction-sections -fdata-sections -fno-exceptions -fno-delete-null-pointer-checks -fno-hosted  -fmessage-length=0 -fno-builtin -DPART_apollo3 -DAM_PACKAGE_BGA -DAM_PART_APOLLO3 -g -MMD -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -fdata-sections -Os -ffunction-sections -Wall -Wextra -nostdlib --param max-inline-insns-single=500 -fno-exceptions -DF_CPU=48000000L -DARDUINO=10809 -DARDUINO_AM_AP3_SFE_BB_ARTEMIS_NANO -DARDUINO_ARCH_APOLLO3 -MMD -MP  -MF output/release/main.d -I.  -I../make  -I../../cmsis/include  -I../source  -I../source/config  -I../../common  -I../../thirdparty  -I../../library  -I../../library/highlevel  -I../../library/lowlevel  -I../../library/middleware -std=gnu99 -c ../source/main.c -o output/release/main.o
In file included from ../source/mcu.h:75,
                 from ../source/main.c:51:
../source/config/RTE_Device.h:82:2: warning: #warning Please select your device here or in the compiler defines section (default set): [-Wcpp]
   82 | #warning Please select your device here or in the compiler defines section (default set):
      |  ^~~~~~~
Linking target: output/release/apollo3-stimer.elf
arm-none-eabi-gcc -DPART_apollo3 -DAM_PACKAGE_BGA -DAM_PART_APOLLO3 -g -MMD -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -fdata-sections -Os -ffunction-sections -Wall -Wextra -nostdlib --param max-inline-insns-single=500 -fno-exceptions -DF_CPU=48000000L -DARDUINO=10809 -DARDUINO_AM_AP3_SFE_BB_ARTEMIS_NANO -DARDUINO_ARCH_APOLLO3 -Os -L -Larmv7e-m/fpu -T ama3b1kk-kbr_rom.ld -I.  -I../make  -I../../cmsis/include  -I../source  -I../source/config  -I../../common  -I../../thirdparty  -I../../library  -I../../library/highlevel  -I../../library/lowlevel  -I../../library/middleware -Wl,--start-group -lc -lg -lstdc++ -lsupc++ -lgcc -lm -Wl,--end-group  -Wl,-Map=output/release/apollo3-stimer.map,--cref,--no-warn-mismatch,--gc-sections  output/release/main.o output/release/system_apollo3.o output/release/startup_apollo3.o -lg -lstdc++ -lsupc++ -lm -lgcc -lc -lnosys -o output/release/apollo3-stimer.elf
arm-none-eabi-objcopy -I elf32-little -O binary output/release/apollo3-stimer.elf output/release/apollo3-stimer.bin
arm-none-eabi-objcopy -O srec output/release/apollo3-stimer.elf output/release/apollo3-stimer.srec
Printing size
arm-none-eabi-size --totals output/release/apollo3-stimer.elf
   text    data     bss     dec     hex filename
   2384    5124       4    7512    1d58 output/release/apollo3-stimer.elf
   2384    5124       4    7512    1d58 (TOTALS)
arm-none-eabi-objdump -D output/release/apollo3-stimer.elf > output/release/apollo3-stimer.lst
arm-none-eabi-nm output/release/apollo3-stimer.elf > output/release/apollo3-stimer-symbol-table.txt
 
../tools/artemis_svl -b 57600 -f output/release/apollo3-stimer.bin /dev/ttyUSB0 -v


Artemis SVL Bootloader

phase:  setup
        cleared startup blip
        Got SVL Bootloader Version: 3
        Sending 'enter bootloader' command

phase:  bootload
        have 5460 bytes to send in 3 frames
        sending frame #1, length: 2048
        sending frame #2, length: 2048
        sending frame #3, length: 1364


Upload complete

Hi,

got it fixed.

the redboard comes with ambiq bootloader and sprkfun btloader, i have used the ambiq bootloader with ambiq_bin2board.py to upload and it works. you need to make the boot pin high at the time of uploading to select the ambiq bootloader.

Cool glad you got it to work. Which pin is the “boot” pin?

I just got it work myself without pulling any pins high. Here’s the command I used in case someone else attempts to upload a non-arduino example.

	${UPLOAD_TOOL_PATH}/ambiq/linux/ambiq_bin2board.py --bin $(CONFIG)/$(TARGET).bin \
	--load-address-blob 0x20000 --magic-num 0xCB -o /tmp/${TARGET} \
	--version 0x0 --load-address-wired 0xC000 -i 6 --options 0x1 \
	-b 115200 -port /dev/ttyUSB0 -r 2 -v

I have a redboard artemis and am trying to get some tensorflow examples running on it. If you dig through the documentation on the artemis chip itself on sparkfun’s website you can find the story on the two different bootloaders and how you have pull pin 47 high. It sounds like they have a circuit that does it for you if you use their loader.

https://cdn.sparkfun.com/assets/8/7/5/3 … _Guide.pdf (page 13)

That being said I tried using their stuff and am confused on something that I feel is simple. The CONFIG and TARGET. I set the export values for them, then try to run the python script and it makes it look like they are not defined.

tom@TomHobbyLaptop:~/Desktop/APOLLOD/tensorflow$ export TARGET=main_nonsecure_wire

tom@TomHobbyLaptop:~/Desktop/APOLLOD/tensorflow$ export CONFIG=.

tom@TomHobbyLaptop:~/Desktop/APOLLOD/tensorflow$ python3 tensorflow/lite/experimental/micro/tools/make/downloads/AmbiqSuite-Rel2.0.0/tools/apollo3_scripts/Spark/ambiq/ambiq_bin2board.py --bin $(CONFIG)/$(TARGET).bin --load-address-blob 0x20000 --magic-num 0xCB -o /tmp/${TARGET} --version 0x0 --load-address-wired 0xC000 -i 6 --options 0x1 -b 115200 -port /dev/ttyUSB0 -r 2 -v

CONFIG: command not found

TARGET: command not found

usage: ambiq_bin2board.py [-h] [-a {0,1,-1}] [–authalgo {0,1}]

[–authI {0,1}] [–authB {0,1}]

[–authkey {8,9,10,11,12,13,14,15}] [-b BAUD]

[–bin APPFILE] [-clean CLEAN] [–child0 CHILD0]

[–child1 CHILD1] [–crcI {0,1}] [–crcB {0,1}]

[–encalgo {0,1}] [–erasePrev {0,1}]

[-i {0,1,2,3,4,5,6,7,32,255}]

[–kek {8,9,10,11,12,13,14,15}]

[–load-address-wired LOADADDRESS_BLOB]

[–load-address-blob LOADADDRESS_IMAGE]

[–loglevel {0,1,2,3,4,5}]

[–magic-num {0xc0,0xcc,0xc1,0xcb,0xcf}] [-o OUTPUT]

[-ota OTADESC] [–options OPTIONS] [-p {0,1,2,3}]

[-port PORT] [-r {0,1,2}] [–raw RAW]

[–split SPLIT] [–version VERSION] [-v]

ambiq_bin2board.py: error: argument --bin: can’t open ‘/.bin’: [Errno 2] No such file or directory: ‘/.bin’

I replaced the CONFIG and TARGET to get rid of them. I can’t get the thing to go into boot. Right now I have the artemus red board running an arduino program that sends out serial so that I can verify that the port is working. I can’t get it to go into boot. The reply that you see below are the arduino serial commands. I might try to pull this pin high on my own just so that I can see if this works…

tom@TomHobbyLaptop:~/Desktop/APOLLOD/tensorflow$ python3 tensorflow/lite/experimental/micro/tools/make/downloads/AmbiqSuite-Rel2.0.0/tools/apollo3_scripts/Spark/ambiq/ambiq_bin2board.py --bin main_nonsecure_wire.bin --load-address-blob 0x20000 --magic-num 0xCB -o /tmp/main_nonsecure_wire --version 0x0 --load-address-wired 0xC000 -i 6 --options 0x1 -b 115200 -port /dev/ttyUSB0 -r 2 -v

Header Size = 0x80

original app_size 0x2c1c4 ( 180676 )

load_address 0xc000 ( 49152 )

app_size 0x2c1c4 ( 180676 )

w0 = 0xcb02c244

Security Value 0x10

w2 = 0x10008080

addrWord = 0xc000

versionKeyWord = 0x0

child0/feature = 0xffffffff

child1 = 0xffffffff

crc = 0xbe3c4e92

Writing to file /tmp/main_nonsecure_wire_OTA_blob.bin

testing: /tmp/main_nonsecure_wire_OTA_blob.bin

Header Size = 0x60

app_size 0x2c244 ( 180804 )

Writing to file /tmp/main_nonsecure_wire_Wired_OTA_blob.bin

Image from 0x0 to 0x2c244 will be loaded at 0x20000

Connecting over serial port /dev/ttyUSB0…

Sending Hello.

No response for command 0x00000000

received bytes 70

[‘0xbe’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’, ‘0x4d’, ‘0x61’, ‘0x6b’, ‘0x65’, ‘0x20’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’, ‘0x4d’, ‘0x61’, ‘0x6b’, ‘0x65’, ‘0x20’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’, ‘0xbc’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’, ‘0xbc’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’]

Failed to respond

Fail

Sending Hello.

No response for command 0x00000000

received bytes 42

[‘0xbe’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’, ‘0xbe’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’, ‘0xbc’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’]

Failed to respond

Fail

Sending Hello.

No response for command 0x00000000

received bytes 56

[‘0xbe’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’, ‘0xbe’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’, ‘0xbc’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’, ‘0xbc’, ‘0x2a’, ‘0xad’, ‘0x95’, ‘0x81’, ‘0x69’, ‘0x74’, ‘0x20’, ‘0x57’, ‘0x4f’, ‘0x52’, ‘0x4b’, ‘0xd’, ‘0xa’]

Failed to respond

Fail

Tries = 3

Upload failed

Can you try to make the 47 pin high manually.

Also make sure that the serial port is given proper permission and defined in the make file.

It looks like a small problem, you are almost there.

It WORKED!!! A couple of notes for other folks, I spent several hours working through this and without this post would never have gotten it.

  1. I used Eagle to open up the board layout to find the boot pin. The easiest place is the the resistor above the LED labeled 13. You jumper the right side of that resistor to 3.3V.

  2. I would trying to reset the chip while jumpering it high, and noticed that it was going into boot. The key here is that you have to keep it jumpered for the duration of the programming event.

Using a wire to put Pin 47 high worked for me, but it seems like there should be a better approach.

Do I need to upgrade the Ambiq Secure Bootloader? Does a new version use the USB chip to pull pin 47 high, like Sparkfun’s does?