source [find target/wmcore.cfg] ### chip_id() -- get chip revision id proc chip_id { } { # make sure the CPU is stopped and in a known state reset halt # Update this array for each unique chip id array set chip_id_array { 0x00000001 "mc200" 0x88110841 "mc200" 0x88130A40 "mw300" 0x88130A41 "mw300" } # read chip revision id register mem2array chip_id 32 0x480b0000 1 foreach {chip_id_val chip_name} [array get chip_id_array] { if { $chip_id(0) == $chip_id_val } { echo [format "Chip id 0x%08x detected" $chip_id(0)] puts -nonewline $chip_name return } } # chip id not known, print chip id for diagnostics echo [format "Unknown chip id 0x%08x" $chip_id(0)] puts -nonewline "unknown" } ### chip_fix() -- do chip specific fixup proc chip_fixup { } { # read chip revision id register mem2array chip_id 32 0x480b0000 1 # Fix for mw300 if { $chip_id(0) == 0x88130A41 } { # Change system clock source to RC32M mwb 0x480a0018 1 # Reset WLAN mwb 0x480a0118 0 } } ### program_image() -- program flash using openocd flash commands # # 1. Reset and halt processor in a known state # 2. Erase the requested flash region and write $filename data at $offset # in the flash proc program_image { offset filename } { # make sure the CPU is stopped and in a known state reset halt # do chip fixup if any chip_fixup # erase the flash region and write file data at the offset flash write_image erase $filename $offset } ### load() -- load any generic application axf image to ram and run ### # # 1. Reset and halt processor in a known state # 2. Load axf image into internal ram of target device # 3. Verify loaded axf image # 4. Pass control to loaded image using its entry point address # # NOTE: Entry point address of axf image can be found using # command: readelf -h proc load { img entry_point } { # make sure the CPU is stopped and in a known state reset halt # do chip fixup if any chip_fixup # load the axf image load_image $img # verify the loaded image verify_image $img # execute the loaded image resume $entry_point } ### sh_load() -- load flashprog.axf (flash tool) image to ram and run ### # # 1. Reset and halt processor in a known state # 2. Enable arm semihosting # 3. Load axf image into internal ram of target device # 4. Verify loaded axf image # 5. Pass control to loaded image using its entry point address # # NOTE: Entry point address of axf image can be found using # command: readelf -h proc sh_load { img entry_point } { # make sure the CPU is stopped and in a known state reset halt # do chip fixup if any chip_fixup # load the axf image load_image $img # verify the loaded image verify_image $img # enable semihosting by default (needed for flashprog) arm semihosting enable # attach handler for halt wmcore.cpu configure -event halted { echo "Flashprog Complete" shutdown } # execute the loaded image resume $entry_point }