Skip to content

Commit

Permalink
Merge pull request #559 from brianesquilona/dev_feature_msd_endpt
Browse files Browse the repository at this point in the history
No-built-in-target implementation for Daplink
  • Loading branch information
brianesquilona authored Feb 27, 2019
2 parents 64359f5 + 2127cee commit 487ab90
Show file tree
Hide file tree
Showing 488 changed files with 3,515 additions and 2,460 deletions.
6 changes: 5 additions & 1 deletion docs/MSD_COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ any file operation (addition, deletion, content change) could be used to trigger
a DAPLink command. Deleting ``ASSERT.TXT`` is actually a DAPLink MSD command in its
own right.

``refresh.act`` This file forces a remount of the DAPLink MSD drive
``refresh.act`` This file forces a remount of the DAPLink MSD drive.

``erase.act`` This file triggers an erase of the target's flash.

``msd_off.act`` Mass storage device can be disabled by this file command regardless of presence of target flash algo for drag and drop. MSD will always be disabled without the target flash algo.

``msd_on.act`` Mass storage device can be enabled back by this file command on bootloader mode only if there is a target flash algo.

### Configuration Commands

``auto_rst.cfg`` This file will turn on Auto Reset mode. In this mode,
Expand Down
97 changes: 85 additions & 12 deletions docs/PORT_BOARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ A board is composed of a Hardware Interface Circuit and target MCU. To create a
- records/board/myboardname.yaml
```
Next create a new file in the `records/board` directory called myboardname.yaml. This file defines the target MCU and allows overrideable board parameters to be configured. The target MCU in this example exists and is a Nordic nRF51822 (16k RAM variant)
Next create a new file in the `records/board` directory called myboardname.yaml. This file defines the target family MCU and allows overrideable board parameters to be configured. The target family MCU in this example exists and is a Nordic nRF51822 (16k RAM variant). More than one target/family can be added to the project and the family can be retargeted by family ID. See `Post-build Board ID and Family ID` section.

```yaml
common:
sources:
board:
- source/board/myboardname.c
target:
- source/target/nordic/nrf51822/target_16.c
- source/target/nordic/target_reset.c
family:
- source/family/nordic/nrf51822/target_16.c
- source/family/nordic/target_reset_nrf51.c
```

This assumes there is already target support present in the codebase. If adding a new target additional steps below will be needed. If the target support exists `source/board/myboardname.c` needs creation with a BOARD ID. To get a BOARD ID email [email protected]
This assumes there is already target support present in the codebase. If adding a new target family is needed, additional steps in [Porting target family guide](PORT_TARGET_FAMILY.md) will be needed. If the target support exists `source/board/myboardname.c` needs creation with a BOARD ID. To get a BOARD ID email [email protected]
```c
/**
* @file myboardname.c
* @brief board ID for myboard
* @file myboard.c
* @brief board_info api for my board
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
Expand All @@ -43,23 +43,59 @@ This assumes there is already target support present in the codebase. If adding
* limitations under the License.
*/
const char *board_id = "0000";
#include "target_family.h"
#include "target_board.h"
const board_info_t g_board_info = {
.board_id = "0x240",
.family_id = kStub_HWReset_FamilyID,
.flags = kEnablePageErase|kEnableUnderResetConnect,
.target_cfg = &target_device,
};
```
The complete fields of board_info api with description is in `source/target/target_board.h`.
```c
// Flags for board_info
enum {
kEnablePageErase = 1, /*!< Enable page programming and sector erase for drag and drop */
kEnableUnderResetConnect = 1<<1, /*!< Enable under reset connection when enabling debug mode */
};
Now running `progen generate -t uvision` will create project files including the new board that can be developed and debugged. For more information about the yaml format [see the project_generator documentation.](https://github.com/project-generator/project_generator/wiki/Getting_started)
typedef struct __attribute__((__packed__)) board_info {
uint16_t infoVersion; /*!< Version number of the board */
uint16_t family_id; /*!< Use to select target family from defined target family ids */
char board_id[5]; /*!< 4-char board ID plus null terminator */
uint8_t _padding[3];
uint32_t flags; /*!< Combination of kEnablePageErase and kEnableUnderResetConnect */
target_cfg_t *target_cfg; /*!< Specific chip configuration for the target and enables MSD when non-NULL */
// fields used by MSD
vfs_filename_t daplink_url_name; /*!< Customize the URL file name */
vfs_filename_t daplink_drive_name; /*!< Customize the MSD DAPLink drive name */
char daplink_target_url[64]; /*!< Customize the target url in DETAILS.TXT */
// some specific board initilization
void (*prerun_board_config)(void); /*!< Specific board debug/ID related initialization */
void (*swd_set_target_reset)(uint8_t asserted); /*!< Boards can customize how to send reset to the target precedence over target family */
uint8_t (*target_set_state)(TARGET_RESET_STATE state); /*!< Boards can customize target debug states in target_reset.h precedence over target family */
uint32_t soft_reset_type; /*!< Boards can override software reset type to VECTRESET or SYSRESETREQ */
} board_info_t;
```
Now running `progen generate -t uvision` will create project files including the new board that can be developed and debugged. Complete development guide is in [Developers Guide](DEVELOPERS-GUIDE.md). For more information about the yaml format [see the project_generator documentation.](https://github.com/project-generator/project_generator/wiki/Getting_started)

### Adding Board to Automated Tests
Update `test/info.py` so the new board has at least one configuration in SUPPORTED_CONFIGURATIONS
```python
SUPPORTED_CONFIGURATIONS = [
# Board ID Firmware Bootloader Target
# Board ID Family ID Firmware Bootloader Target
...
( 0x240, 'k20dx_frdmk64f_if', 'k20dx_bl', 'FRDM-K64F' ),
( 0x0240, VENDOR_TO_FAMILY('NXP', 1), 'k20dx_frdmk64f_if', 'k20dx_bl', 'FRDM-K64F' ),
...
]
```
Configration Fields
* Board ID - The ID assigned to the board type.
* Family ID - Use to select or identify target family from defined target family or custom ones. Note that common or stub families are supported which supports hw_reset, sw_vectreset or sw_sysreset. More details in [Porting target family guide](PORT_TARGET_FAMILY.md).
* Firmware - The name of the firmware as shown in projects.yaml.
* Bootloader - The name of the bootloader firmware as shown in projects.yaml. Only required on HICs with a DAPLink bootloader.
* Target - Name of the target for this board.
Expand All @@ -69,3 +105,40 @@ Configration Fields
You may need to update one or more other dictionaries. See comments in the code for guidance.

See [Automated Tests](AUTOMATED_TESTS.md) for more information related to automated testing.

# Post-build Board ID and Family ID
Board ID and Family ID can be overwritten by `tools/post_build_scpript.py`. This is helpful for supporting existing families and adding board IDs to the database without the need to compile DAPLink. Board ID can uniquely identify the target board while family ID can select which target family to support.
```
usage: post_build_script.py [-h] [--board-id BOARD_ID] [--family-id FAMILY_ID]
[--bin-offset BIN_OFFSET]
input output

post Build tool for Board ID, Family ID and CRC generation

positional arguments:
input Hex or bin file to read from.
output Output base file name to write crc, board_id and
family_id.

optional arguments:
-h, --help show this help message and exit
--board-id BOARD_ID board id to for the target in hex
--family-id FAMILY_ID
family id to for the target in hex
--bin-offset BIN_OFFSET
binary offset in hex
```
Note however that run time board id and family id can be present in the code and DAPLink will use this if it has non-zero value. From `source/hic_hal_target_config.h`
```
/**
@struct target_cfg_t
@brief The firmware configuration struct has unique about the chip its running on.
*/
...
typedef struct target_cfg {
...
const char *rt_board_id; /*!< If assigned, this is a flexible board ID */
uint16_t rt_family_id; /*!< If assigned, this is a flexible board ID */
} target_cfg_t;
...
```
36 changes: 31 additions & 5 deletions docs/PORT_TARGET.md → docs/PORT_TARGET_FAMILY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Adding A New Target
Adding new target support requires creating a flash algo blob and the implementation for some stub functions. Target support is added to the `source/target/<mfg>/<target>` directory. At minimum, 3 files are needed. The first is `source/target/<mfg>/target_reset.c`
# Adding A New Target Family
Adding new target support requires creating a flash algo blob and the implementation for some stub functions. Target support is added to the `source/family/<mfg>/<target>` directory. At minimum, 3 files are needed. The first is `source/target/<mfg>/target_reset.c`

```c
/**
Expand Down Expand Up @@ -59,7 +59,7 @@ uint8_t security_bits_set(uint32_t addr, uint8_t *data, uint32_t size)
}
```
A flash algorithm blob is needed to program the target MCUs internal (or external) flash memory. This blob contains position independent functions for erasing, reading and writing to the flash controller. Flash algorithm blobs are created from the [FlashAlgo project.](https://github.com/mbedmicro/FlashAlgo) An example blob is shown below and would be added to `source/target/<mfg>/<targetname>/flash_blob.c`
A flash algorithm blob is needed to program the target MCUs internal (or external) flash memory. This blob contains position independent functions for erasing, reading and writing to the flash controller. Flash algorithm blobs are created from the [FlashAlgo project.](https://github.com/mbedmicro/FlashAlgo) An example blob is shown below and would be added to `source/family/<mfg>/<targetname>/flash_blob.c`
```c
/**
Expand Down Expand Up @@ -135,7 +135,7 @@ static const program_target_t flash = {
```

The last required file is the target MCU description file `source/targets/<mfg>/<targetname>/target.c` This file contains information about the size of ROM, RAM and sector operations needed to be performed on the target MCU while programming an image across the drag-n-drop channel.
The last required file is the target MCU description file `source/family/<mfg>/<targetname>/target.c` This file contains information about the size of ROM, RAM and sector operations needed to be performed on the target MCU while programming an image across the drag-n-drop channel.

```c
/**
Expand Down Expand Up @@ -175,5 +175,31 @@ target_cfg_t target_device = {
.flash_algo = (program_target_t *) &flash,
};
```
At this point these target specific files could be added to a board build and developed.

At this point these target specific files could be added to a board build and developed.
Complete target configuration api is located in `source/hic_hal_target_config.h`
```c
/**
@struct target_cfg_t
@brief The firmware configuration struct has unique about the chip its running on.
*/
typedef struct target_cfg {
uint32_t sector_size; /*!< Number of bytes in a sector used by flash erase and filesystem */
uint32_t sector_cnt; /*!< Number of sectors a device has */
uint32_t flash_start; /*!< Address of the application entry point */
uint32_t flash_end; /*!< Address where the flash ends */
uint32_t ram_start; /*!< Lowest contigous RAM address the application uses */
uint32_t ram_end; /*!< Highest contigous RAM address the application uses */
program_target_t *flash_algo; /*!< A pointer to the flash algorithm structure */
uint8_t erase_reset; /*!< Reset after performing an erase */
const sector_info_t* sectors_info;
int sector_info_length;
region_info_t extra_flash[MAX_EXTRA_FLASH_REGION + 1]; /*!< Extra flash regions */
region_info_t extra_ram[MAX_EXTRA_RAM_REGION + 1]; /*!< Extra RAM regions */
const char *rt_board_id; /*!< If assigned, this is a flexible board ID */
uint16_t rt_family_id; /*!< If assigned, this is a flexible board ID */
} target_cfg_t;
```

# Supported Target Families
A HIC can target all supported families available and a post build script can modify a board's family id to point to the correct family. See [Porting board guide](PORT_BOARD.md)
33 changes: 32 additions & 1 deletion projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module:
- records/daplink/drag-n-drop.yaml
- records/daplink/settings.yaml
- records/daplink/settings_rom_stub.yaml
- records/daplink/target_board.yaml
if: &module_if
- *module_tools
- records/usb/usb-core.yaml
Expand All @@ -33,6 +34,8 @@ module:
- records/daplink/settings.yaml
- records/daplink/settings_rom.yaml
- records/daplink/interface.yaml
- records/daplink/target_family.yaml
- records/daplink/target_board.yaml
# HICs
hic_k20dx: &module_hic_k20dx
- records/rtos/rtos-cm3.yaml
Expand Down Expand Up @@ -61,22 +64,46 @@ projects:
- *module_bl
- *module_hic_kl26z
- records/board/kl26z_bl.yaml
kl26z_if:
- *module_if
- *module_hic_kl26z
- records/family/all_family.yaml
k20dx_bl:
- *module_bl
- *module_hic_k20dx
- records/board/k20dx_bl.yaml
k20dx_if:
- *module_if
- *module_hic_k20dx
- records/family/all_family.yaml
lpc11u35_if:
- *module_if
- *module_hic_lpc11u35
- records/family/all_family.yaml
lpc4322_bl:
- *module_bl
- *module_hic_lpc4322
- records/board/lpc4322_bl.yaml
lpc4322_if:
- *module_if
- *module_hic_lpc4322
- records/family/all_family.yaml
sam3u2c_bl:
- *module_bl
- *module_hic_sam3u2c
- records/board/sam3u2c_bl.yaml
sam3u2c_if:
- *module_if
- *module_hic_sam3u2c
- records/family/all_family.yaml
stm32f103xb_bl:
- *module_bl
- *module_hic_stm32f103xb
- records/board/stm32f103xb_bl.yaml
stm32f103xb_if:
- *module_if
- *module_hic_stm32f103xb
- records/family/all_family.yaml
sam3u2c_mkit_dk_dongle_nrf5x_if:
- *module_if
- *module_hic_sam3u2c
Expand Down Expand Up @@ -225,7 +252,7 @@ projects:
- *module_if
- *module_hic_lpc4322
- records/board/lpc54608xpresso.yaml
lpc4322_lpc55S69xpresso_if:
lpc4322_lpc55s69xpresso_if:
- *module_if
- *module_hic_lpc4322
- records/board/lpc55S69xpresso.yaml
Expand Down Expand Up @@ -529,3 +556,7 @@ projects:
- *module_if
- *module_hic_max32620
- records/board/max32625mbed.yaml
max32620_if:
- *module_if
- *module_hic_max32620
- records/family/all_family.yaml
6 changes: 3 additions & 3 deletions records/board/6LoWPAN_BorderRouterETHERNET.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ common:
sources:
board:
- source/board/6LoWPAN_BorderRouterETHERNET.c
target:
- source/target/freescale/k64f/target.c
- source/target/freescale/target_reset_Kseries.c
family:
- source/family/freescale/k64f/target.c
- source/family/freescale/target_reset_Kseries.c

6 changes: 3 additions & 3 deletions records/board/6LoWPAN_BorderRouterHAT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ common:
sources:
board:
- source/board/6LoWPAN_BorderRouterHAT.c
target:
- source/target/freescale/k64f/target.c
- source/target/freescale/target_reset_Kseries.c
family:
- source/family/freescale/k64f/target.c
- source/family/freescale/target_reset_Kseries.c

6 changes: 3 additions & 3 deletions records/board/6LoWPAN_BorderRouterUSB.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ common:
sources:
board:
- source/board/6LoWPAN_BorderRouterUSB.c
target:
- source/target/freescale/k64f/target.c
- source/target/freescale/target_reset_Kseries.c
family:
- source/family/freescale/k64f/target.c
- source/family/freescale/target_reset_Kseries.c

6 changes: 3 additions & 3 deletions records/board/96b_nitrogen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ common:
sources:
board:
- source/board/96b_nitrogen.c
target:
- source/target/nordic/nrf5x/target.c
- source/target/nordic/target_reset_nrf52.c
family:
- source/family/nordic/nrf5x/target.c
- source/family/nordic/target_reset_nrf52.c
5 changes: 2 additions & 3 deletions records/board/FF1705_L151.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ common:
sources:
board:
- source/board/FF1705_L151.c
source:
- source/target/st/xDot-L151/target.c
- source/target/st/xDot-L151/target_reset.c
family:
- source/family/st/xDot-L151/target.c
6 changes: 3 additions & 3 deletions records/board/archble.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ common:
sources:
board:
- source/board/archble.c
target:
- source/target/nordic/nrf51822/target_16.c
- source/target/nordic/target_reset.c
family:
- source/family/nordic/nrf51822/target_16.c
- source/family/nordic/target_reset_nrf51.c
6 changes: 3 additions & 3 deletions records/board/archlink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ common:
sources:
board:
- source/board/archlink.c
target:
- source/target/nordic/nrf51822/target_16.c
- source/target/nordic/target_reset.c
family:
- source/family/nordic/nrf51822/target_16.c
- source/family/nordic/target_reset_nrf51.c
5 changes: 2 additions & 3 deletions records/board/archmax.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ common:
sources:
board:
- source/board/archmax.c
target:
- source/target/st/stm32f407/target.c
- source/target/st/target_reset.c
family:
- source/family/st/stm32f407/target.c
5 changes: 2 additions & 3 deletions records/board/archpro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ common:
sources:
board:
- source/board/archpro.c
target:
- source/target/nxp/lpc1768/target.c
- source/target/nxp/target_reset.c
family:
- source/family/nxp/lpc1768/target.c
5 changes: 2 additions & 3 deletions records/board/arm_watch_efm32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ common:
sources:
board:
- source/board/arm_watch_efm32.c
target:
- source/target/siliconlabs/efm32gg/target.c
- source/target/siliconlabs/target_reset.c
family:
- source/family/siliconlabs/efm32gg/target.c
Loading

0 comments on commit 487ab90

Please sign in to comment.