Slotcar Platooning Compilation And Code Upload

Z DCEwiki
Verze z 23. 4. 2014, 14:08, kterou vytvořil Hermaiv2 (diskuse | příspěvky) (→‎How to upload bootloader to chip)
(rozdíl) ← Starší verze | zobrazit aktuální verzi (rozdíl) | Novější verze → (rozdíl)
Skočit na navigaci Skočit na vyhledávání

Compilation

  • Main program code main.c is located in folder \onboard\fw\projects\app
  • Compilation is made by Makefile, so we have to use the "make" command in command line
  • Cleaning is made by command "make clean"

Communication

  • Plug the Nordic adapter to USB!
  • start Command line and navigate to the folder <SWRoot>/onboard/fw/app, where <SWRoot> contains the folders and files from Mira
  • First, we have to set the right address of the car. That is done by "set addr=X" command, where X is the addres number. Do not use spaces between = and X
  • we can start basic communication by command "term"
  • Afterward, the system should connect to the address X and display it.
  • Once communication is established we can see all availible commands by writting "help"
    • For example, we can start motor with command "pwm 800"
  • The other option is to start the terminal with "term X"', where X is the address of the car with which you want to communicate. For this to work your Command line has to be in the folder <SWRoot>/sw/nqterm
  • To change the address of the car (default is 0), ater connection to the car type "setaddr X", where X is the new address. Then select y.

Code upload

  • When we have the right address, just use the command "load" in the app folder
  • How to upload code to a dead processor:
    • unplug the car from power supply
    • in command line in folder ondboard/fw/app, run set addr=X and then run load.bat.
    • Connect the car to power supply. Then in the car booloader runs for a while and load.bat keeps trying to connect.
    • Bootloader file should take some working code (e.g. the default one) and upload it to the car

Change the address of car

  • Connect to the car with the "term" command
  • Change the address of car with "setaddr X", where X is the requested number

How to upload bootloader to chip

  • Obtain discovery kit with stm32f4, at this page www.st.com/stm32f4-discovery you can find the documentation for it.
  • You will use external SWD connector on the discovery kit, so you need to set jumpers to right possition. Our situation for Discovery kit with with STM32F407VG MCU is shown here on page 15. At that page you can see CN3 connector and for communication with external chip you need to remove jumpers.
  • Next step is connect signals on SWD connector on discovery kit with same signals on board of your car. You need to connect signals GND, SWDIO and SWCLK. Pinout from the left (the side of camera connector): 1=SWDIO, 2=SWDCLK, 5=GND. Connect 1,2,5. On the Discovery Kit: 2=SWDCLK, 3=GND, 4=SWNIO.
  • In this step you need to install ST-Link utility, you can download it here.
  • After you connect discovery kit with your board, you can plug discovery kit into your PC and start ST-Link utility.
  • Now you can connect ST-Link with your target chip by clicking "connect to the target" button. after you are successfully connected you can open file with your bootloader. You need to upload bootloader.bin not bootloader.hex. Then you can upload code to chip by clicking Menu -> Target -> program and verify.
  • Tips:
    • There is a red LED on board which indicates if there is a successful connection between radio and MCU. When the LED is ON communication is NOT successful. When the LED is OFF communication IS successful. The LED should turn off after a short moment after start.
    • Another tip is about ST-Link utility. It can happen that it says "no target connected" and if you are sure that you are connected then you can try reconect your discovery kit and restart ST-Link utility also. Another possibility is try to reset the chip on car manualy by connect RESET pin with GND then click connect button in ST-Link and then release RESET.

Back to Slotcar platoons