newaetech / cw310-bergen-board

CW310 - Kintex FPGA ('Bergen Board') Target
3 stars 4 forks source link

How to load firmware for SAM3X? #7

Open houdonghui1 opened 1 year ago

houdonghui1 commented 1 year ago

Hello engineers!! How can I load the firmware on the CW310 board onto the SAM3X on my board? Under what operating system can software be used to load firmware onto the MCU? Is there a method explanation?

colinoflynn commented 1 year ago

Hello,

The SAM3X firmware uses the same firmware loading as ChipWhisperer, so it works in Python (Windows or Linux). The FW update mechanism is described at https://chipwhisperer.readthedocs.io/en/latest/scope-api.html#firmware-update .

If the SAM3X is blank, use:

import chipwhisperer as cw
programmer = cw.SAMFWLoader(scope=None)
programmer.program(<port>, 'CW310.bin')

Where is COMx, /dev/ttyUSB, etc depending on platform. You can also force erase the SAM3X with the 'erase' pins (jumper with wire/paperclip). But you can use the ChipWhisperer API to enter bootloader mode automatically too.

CW310 is built from running make here: https://github.com/newaetech/cw310-bergen-board/tree/main/microfw/CW310/src

ViennaPan commented 10 months ago

Hi Colinoflynn, When I trying to do SAM3X with: programmer = cw.SAMFWLoader(scope=target) programmer.enter_bootloader(really_enter=True)

I see all the power are down in CW310 board, and cannot get the target for ever. Do you know why this occurring? Before this erasing, I can use the USB-C Data to get the target and do fpga_read and fpga_write already. Now all are not working as all power off. Thanks, Vienna

colinoflynn commented 10 months ago

Hello,

This will just erase the SAM3X, does it come back up as a serial port? Are you on Windows or Linux? If on Linux you can check dmesg to see if the SAM3X comes up as a serial port. If you press the "USB RST" button, it will reenumeate the SAM3X which might make it more obvious (or unplug/replug USB cable):

image

The command from there is:

import chipwhisperer as cw
programmer = cw.SAMFWLoader(scope=None)
programmer.program(<port>, 'CW310.bin')

Where CW310.bin is available here. Just download to your local file.

If the serial port isn't coming up, it could be the erase failed. There is an "erase" jumper (pins) on the PCB, you can short with a paperclip/wire which should also force the erase.

image

ViennaPan commented 10 months ago

Hi colinoflynn, Your method works. As the target cannot be get, I have to use the scope=None instead of scope=target in cw.SAMFWLoader. And the program is working. Thank you very much for the quick guidance. Regards, Vienna

ViennaPan commented 10 months ago

Hi colinoflynn, The bin file "CW310 is built from running make here: https://github.com/newaetech/cw310-bergen-board/tree/main/microfw/CW310/src" has a problem that the byte counter of the bit 0 and bit 1 are by default as 1, which is not working for plaintext and key write (any other 16 bytes write will be failed: image I added a workaround to not use the lowest 2 bits and find out that it is not supporting bit index 5 and index 6. Could you help to check why? Thanks, Vienna