Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions cfg/sam3s_rpi_sysfs_check.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
source [find interface/matrix-creator.cfg]
transport select jtag
adapter_khz 128


jtag newtap em358 cpu \
-irlen 4\
-ircapture 0x1\
-irmask 0xf \
-expected-id 0x3ba00477

jtag newtap em357 bs \
-irlen 4 \
-ircapture 0x0e \
-irmask 0xf \
-expected-id 0x069AA62B

jtag newtap xc6sxl4.fpga fpga \
-irlen 6 \
-ircapture 0x35 \
-irmask 0x3f \
-expected-id 0x24000093

jtag newtap sam3n.cpu cpu \
-irlen 4\
-ircapture 0x1\
-irmask 0xf \
-expected-id 0x4ba00477

target create sam3n.cpu cortex_m -endian little -chain-position 3
flash bank flash0 at91sam3 0x00400000 0 0 0 sam3n.cpu

#source at91sam3nXX.cfg
init
halt
wait_halt
sleep 10
at91sam3 gpnvm show all
flash info 0
flash probe 0
flash verify_bank 0 blob/ch.bin 0
reset run
shutdown
25 changes: 16 additions & 9 deletions sam3-program.bash
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ function try_program() {
echo $RES

sleep 0.5
reset_mcu
reset_mcu
sleep 1
}

function enable_program() {
Expand All @@ -73,13 +74,17 @@ function enable_program() {
}

function check_firmware() {
COMPARE_VERSION=$(diff <(./firmware_info) <(cat mcu_firmware.version)|wc -l)

if [ "$COMPARE_VERSION" == "0" ];then
echo 1
else #failed
echo 0
fi
local result=1
local output=$(openocd -f cfg/sam3s_rpi_sysfs_check.cfg 2>&1)
if [[ "$output" == *"sam3-gpnvm1: 0"* ]]; then
# wrong bootmode
result=0
fi
if [[ "$output" == *"contents differ"* ]]; then
# new or no firmware
result=0
fi
echo "$result"
}

for i in 4 17 18 19 20 22 23 27
Expand All @@ -101,9 +106,11 @@ then
echo "SAM3 MCU was programmed before. Not programming it again."
exit 0
fi

enable_program

count=0
while [ $count -lt 30 ]; do
while [ $count -lt 5 ]; do
TEST=$(try_program)
if [ "$TEST" == "1" ];then
CHECK=$(check_firmware)
Expand Down