lpc-field

Template project for programming NXP's LPC1768 MCUs
Log | Files | Refs | README | LICENSE

README.md (2731B)


      1 ## Template for programming LPC1768 MCU
      2 If you don't like Keil (obviously) and also want to go deeper than mbed's abstraction layers, try this to build your LPC1768 project.
      3 - Sources used:
      4     - [libopencm3](https://github.com/libopencm3/libopencm3)
      5     - [CMSIS drivers for LPC1768](https://drive.google.com/open?id=1qdtXqvLqQoIKSMrtabgRIH5fCs94qsPv)
      6 
      7 ### Structure
      8 
      9 ```
     10 src
     11 ├── app
     12 ├── globals
     13 └── shared
     14 ```
     15 
     16 The shared directory contains library and driver sources which can be shared between applications.
     17 The app directory contains code for the main application.
     18 The global directory can be used for soem definitions that are accessible for all parts of the project (e.g. `version.h`)
     19 Each subdirectory has a make module that sets up srouces and include paths for that specific part of the project.
     20 The main Makefile at the root brings in all definitions of the make modules and builds the application to the `build`
     21 directory.
     22 
     23 User can create additional subdirectories for different applications like bootloader and etc. The linker script,
     24 Makefile should be modified to create the binaries and executable based on the project needs.
     25 
     26 ### Building
     27 - Dependencies: 
     28     - `arm-none-eabi-gcc` compiler
     29     - make
     30 
     31 ```
     32 git clone https://github.com/mdnrz/lpc-field.git
     33 cd lpc-field
     34 make
     35 ```
     36 The object files and the final `.elf`, `.bin`, `.hex`, and `.map` files will be on the `build` directory. The name
     37 of the final output files will be based on the latest tag and commit hash and updates automatically with new
     38 commits.
     39 
     40 Also a copy of the latest firmware will be created as `fw.elf` which will be used in `fw-debug` target.
     41 
     42 ### Flashing
     43 - Dependencies:
     44     - openocd
     45     - jlink or ft232h debugger
     46 
     47 By default the ft232h board is used as debug interface
     48 (look
     49 [here](https://github.com/m3y54m/cjmcu-ft232hq-programmer?utm_source=pocket_shared)
     50 for more information)
     51 User can change the debugger on the root Makefile by changing the `OPENOCD_INTERFACE` variable.
     52 
     53 ```
     54 make flash-app
     55 ```
     56 
     57 ### Debugging
     58 - Dependencies:
     59     - arm-none-eabi-gdb (Can be changed by `DB` variable in Makefile)
     60     - openocd
     61     - [cmsis-svd](https://github.com/cmsis-svd/cmsis-svd) python package (optional)
     62      
     63 ```
     64 make fw-debug
     65 ```
     66 This command flashes the latest firmware on the board, starts an openocd process in the background, runs
     67 gdb and connects to the remote target and brings up gdb tui interface halted at the `main()`.
     68 
     69 The `.gdbinit` file contains configs and commands executed at gdb startup. If you don't want to use svd 
     70 when debugging, comment out these two lines:
     71 ```
     72 source /home/mehdi/extra/gits/svd-tools/gdb-svd.py
     73 svd LPC176x5x.svd
     74 ```
     75 Quiting gdb will also automatically kill the openocd process.