Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microbit v2 specific features #763

Merged
merged 57 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
2138b49
Incompatible image detection feature
gerargz May 20, 2020
a12b073
Fat binaries feature
gerargz May 20, 2020
57b5131
Interface main task changes
gerargz May 20, 2020
a6b95c8
Add microbit specific features
gerargz May 21, 2020
fb73881
Sync latest features including:
gerargz Aug 21, 2020
1e096f6
Add Power LED sleep state ON/OFF support in I2C comms interface
gerargz Aug 22, 2020
26542ef
Fix FlexIO clock ranges in assert
gerargz Aug 26, 2020
e4ce4df
#80 Add incompatible image detection feature in details.txt file. Add…
gerargz Sep 1, 2020
746d873
Validate allowed filename extensions in the I2C Flash interface (.bin…
gerargz Sep 1, 2020
d5f8ef2
Update power handling for off/stand-by modes
gerargz Sep 3, 2020
41a5bef
#33 Update error app from https://github.com/microbit-foundation/stan…
gerargz Sep 3, 2020
e8480a6
Update wake from deep sleep handling
gerargz Sep 4, 2020
4286a45
Red LED updates
gerargz Sep 7, 2020
03a2b4e
Delay deep sleep requests after we have determined if USB is enumerat…
gerargz Sep 10, 2020
3a155cc
Reset usb timeout counters for the next time we want to connect
gerargz Sep 10, 2020
555a919
Enter light sleep when idle
gerargz Sep 10, 2020
731558d
Send event for wake on edge and release the interrupt line on every n…
gerargz Sep 10, 2020
45ce359
Add I2C nop command on the comms interface. Doing an i2c write witht …
gerargz Sep 10, 2020
9548de6
Prevent Nop cmd from overwriting response from previous i2c write
gerargz Sep 11, 2020
a8558c3
Add I2C property to enable/disable automatic light sleep when idle
gerargz Sep 11, 2020
e6c7ef2
Temporal fix for broken details.txt
gerargz Sep 11, 2020
4bbad2a
Prevent entering light sleep if I2C transaction is ongoing
gerargz Sep 11, 2020
030847b
Temporal modification of USB max power to 300mA
gerargz Sep 11, 2020
957eff5
Reset the Power LED sleep state when waking up the NRF with COMBINED_…
gerargz Sep 11, 2020
e62fbae
Do not clear I2C buffers after waking up from VLPS
gerargz Sep 11, 2020
7a5ee8d
Remove references to i2c flash status cmd
gerargz Sep 11, 2020
a48a713
Prevent entering light-sleep mode when USB Host does re-enumeration (…
gerargz Sep 14, 2020
147b1b4
Set usb_state to disconnected immediately after cable deatch, instead…
gerargz Sep 15, 2020
ec3fec9
Lower battery voltage threshold for determining power source to avoid…
gerargz Sep 15, 2020
831fed9
I2C Flash interface updates
gerargz Sep 30, 2020
5d3b4e8
Fix lost serial bytes during flash operations
gerargz Oct 1, 2020
8eb2c4c
Move I2C files, to board specific folder
gerargz Oct 2, 2020
7e7c3fb
Don't enable bandgap reference during low power modes
gerargz Oct 2, 2020
6ac64b9
Low power updates:
gerargz Oct 3, 2020
f1bb93e
Request debugger power down after target is set to RUN state.
gerargz Oct 6, 2020
d94d02f
Increase priority of I2C
gerargz Oct 7, 2020
b1d3f2b
I2C low power updates
gerargz Oct 7, 2020
38fe9bc
#64 Assume "PC connected" at the start of USB communication instead o…
gerargz Oct 7, 2020
6f05cf9
#86 Change type of reset during button press and block button handlin…
gerargz Oct 9, 2020
e851540
#84 #82 Add hook for detecting when flashing has completed to return …
gerargz Oct 9, 2020
6a60f2b
#20 LED Behavior updates
gerargz Oct 9, 2020
a4a5c03
#62 Take ADC measurements for VIN and battery
gerargz Oct 13, 2020
e4e9b2d
#87 WebUSB LED blink workaround
gerargz Oct 13, 2020
9ff7357
#86 Return reset button to default state after flashing finishes to i…
gerargz Oct 14, 2020
1d78ae6
#92 Erase flash storage with erase.act file and allow filesize of up …
gerargz Oct 14, 2020
258d0b7
#54 Bump DAPLink version to 255
gerargz Oct 14, 2020
2dbce5c
#87 Improve power source handling with edge connector
gerargz Oct 15, 2020
5d90bf4
#95 Ignore out of bounds read for the storage file
gerargz Oct 15, 2020
1436bdc
#99 Enable flash protection on DAPLink bootloader region
gerargz Oct 18, 2020
2482d2a
Formatting and indentation
gerargz Jan 6, 2021
f3d9350
Add copyright and license header
gerargz Jan 6, 2021
1255534
Merge remote-tracking branch 'upstream/master' into microbit_features
gerargz Jan 9, 2021
7e18836
Consistent use of static for function
mbrossard Jan 9, 2021
3835a97
Make microbit bootloader optional for kl27z HIC
mbrossard Jan 13, 2021
de84e4c
Change storage API to avoid armgcc warning
gerargz Jan 22, 2021
9d09263
remove arm copyright from newly added files
gerargz Aug 12, 2021
44a2522
Updates after review:
gerargz Aug 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/MSD_COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ data fast enough from DAPLink and an overflow occurs the text ```<DAPLink:Overfl
will show up in the serial data. Serial overflow reporting is turned off by default.

``ovfl_off.cfg`` This file turns off serial overflow reporting.


``comp_on.cfg`` This file turns on the incompatible target image detection. The interface project must define a board specific `board_detect_incompatible_image()` function with the criteria to validate the target image over the first 12 vectors. Otherwise, the incompatible target image detection won't have an effect.

``comp_off.cfg`` This file turns off the incompatible target image detection (off by default).
4 changes: 4 additions & 0 deletions projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ projects:
- *module_if
- *module_hic_kl27z
- records/family/all_family.yaml
kl27z_microbit_bl:
- *module_bl
- records/hic_hal/kl27z.yaml
- records/board/kl27z_microbit_bl.yaml
k20dx_bl:
- *module_bl
- records/hic_hal/k20dx.yaml
Expand Down
4 changes: 4 additions & 0 deletions records/board/kl27z_microbit_bl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
common:
sources:
board:
- source/board/kl27z_microbit_bl.c
6 changes: 5 additions & 1 deletion records/board/microbitv2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ common:
- CDC_LED_DEF=GPIO_LED_ON
- MSC_LED_DEF=GPIO_LED_ON
- USB_PROD_STR="BBC micro:bit CMSIS-DAP"
- IO_CONFIG_OVERRIDE
- DELAY_FAST_CYCLES=2U
flit marked this conversation as resolved.
Show resolved Hide resolved
includes:
- source/board/microbitv2
sources:
board:
- source/board/microbitv2/microbitv2.c
- source/board/microbitv2/
target:
- source/family/nordic/nrf5x/target.c
- source/family/nordic/target_reset_nrf52.c
2 changes: 1 addition & 1 deletion records/tools/version.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
common:
macros:
- DAPLINK_VERSION=254
- DAPLINK_VERSION=255
81 changes: 81 additions & 0 deletions source/board/kl27z_microbit_bl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @file kl27z_microbit_bl.c
* @brief board ID and meta-data for the hardware interface circuit (HIC) based on the NXP KL27Z
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
gerargz marked this conversation as resolved.
Show resolved Hide resolved
* Copyright 2020 NXP
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "target_config.h"
#include "daplink_addr.h"
#include "compiler.h"
#include "target_board.h"
#include "target_family.h"
#include "fsl_device_registers.h"
#include "gpio.h"

// Warning - changing the interface start will break backwards compatibility
COMPILER_ASSERT(DAPLINK_ROM_IF_START == KB(32));
COMPILER_ASSERT(DAPLINK_ROM_IF_SIZE == (KB(128) - KB(32) - KB(1)));

/**
* List of start and size for each size of flash sector
* The size will apply to all sectors between the listed address and the next address
* in the list.
* The last pair in the list will have sectors starting at that address and ending
* at address start + size.
*/
static const sector_info_t sectors_info[] = {
{DAPLINK_ROM_IF_START, 1024},
};

// kl26z128 target information
target_cfg_t target_device = {
.sectors_info = sectors_info,
.sector_info_length = (sizeof(sectors_info))/(sizeof(sector_info_t)),
.flash_regions[0].start = DAPLINK_ROM_IF_START,
.flash_regions[0].end = DAPLINK_ROM_IF_START + DAPLINK_ROM_IF_SIZE,
.flash_regions[0].flags = kRegionIsDefault,
.ram_regions[0].start = 0x1FFFE000,
.ram_regions[0].end = 0x20006000,
};

//bootloader has no family
const target_family_descriptor_t *g_target_family = NULL;

const board_info_t g_board_info = {
.info_version = kBoardInfoVersion,
.board_id = "0000",
.daplink_url_name = "HELP_FAQHTM",
.daplink_drive_name = "MAINTENANCE",
.daplink_target_url = "https://microbit.org/device/?id=@B&v=@V&bl=1",
.target_cfg = &target_device,
};

bool reset_button_pressed()
{
bool btn_pressed = false;
// Bypass button check if we are waking from Low Leakage Wakeup Reset
if (RCM->SRS0 & RCM_SRS0_WAKEUP_MASK) {
btn_pressed = false;
}
else {
btn_pressed = gpio_get_reset_btn();
}

return btn_pressed;
}
167 changes: 167 additions & 0 deletions source/board/microbitv2/IO_Config_Override.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/**
* @file IO_Config_Override.h
* @brief Alternative IO for KL27Z based Hardware Interface Circuit
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef __IO_CONFIG_H__
#define __IO_CONFIG_H__

#include "MKL27Z4.h"
#include "compiler.h"
#include "daplink.h"

// This GPIO configuration is only valid for the KL27 HIC
COMPILER_ASSERT(DAPLINK_HIC_ID == DAPLINK_HIC_ID_KL27Z);


// Debug Port I/O Pins

// SWCLK Pin PTC6
#define PIN_SWCLK_PORT PORTC
#define PIN_SWCLK_GPIO FGPIOC
#define PIN_SWCLK_BIT (6)
#define PIN_SWCLK (1<<PIN_SWCLK_BIT)

// SWDIO Pin PTC5
#define PIN_SWDIO_PORT PORTC
#define PIN_SWDIO_GPIO FGPIOC
#define PIN_SWDIO_BIT (5)
#define PIN_SWDIO (1<<PIN_SWDIO_BIT)

// nRESET Pin PTA20
#define PIN_nRESET_PORT PORTA
#define PIN_nRESET_GPIO PTA
#define PIN_nRESET_BIT (20)
#define PIN_nRESET (1<<PIN_nRESET_BIT)

// Debug Unit LEDs

// HID_LED PTB0
#define PIN_HID_LED_PORT PORTB
#define PIN_HID_LED_GPIO PTB
#define PIN_HID_LED_BIT (0)
#define PIN_HID_LED (1<<PIN_HID_LED_BIT)
#define PIN_HID_LED_MUX_ALT (0)

// MSC_LED PTB0
#define PIN_MSC_LED_PORT PORTB
#define PIN_MSC_LED_GPIO PTB
#define PIN_MSC_LED_BIT (0)
#define PIN_MSC_LED (1<<PIN_MSC_LED_BIT)
#define PIN_MSC_LED_MUX_ALT (0)

// CDC_LED PTB0
#define PIN_CDC_LED_PORT PORTB
#define PIN_CDC_LED_GPIO PTB
#define PIN_CDC_LED_BIT (0)
#define PIN_CDC_LED (1<<PIN_CDC_LED_BIT)
#define PIN_CDC_LED_MUX_ALT (0)

// Volatge monitor pins

// Battery Voltage monitor PTB1
#define PIN_VMON_BAT_PORT PORTB
#define PIN_VMON_BAT_GPIO PTB
#define PIN_VMON_BAT_BIT (1)
#define PIN_VMON_BAT (1<<PIN_VMON_BAT_BIT)
#define PIN_VMON_BAT_ALT_MODE (kPORT_PinDisabledOrAnalog)
#define PIN_VMON_BAT_ADC_CH (9)
#define PIN_VMON_BAT_ADC_MUX (0)

// Enable Battery Voltage monitor PTC3
#define PIN_RUN_VBAT_SENSE_PORT PORTC
#define PIN_RUN_VBAT_SENSE_GPIO PTC
#define PIN_RUN_VBAT_SENSE_BIT (3)
#define PIN_RUN_VBAT_SENSE (1<<PIN_RUN_VBAT_SENSE_BIT)

// Reset pins

// SW RESET BUTTON PTD4
#define PIN_SW_RESET_PORT PORTD
#define PIN_SW_RESET_GPIO PTD
#define PIN_SW_RESET_BIT (4)
#define PIN_SW_RESET (1<<PIN_SW_RESET_BIT)
#define SW_RESET_PRESSED (0)
#define SW_RESET_NOT_PRESSED (1)
#define PIN_SW_RESET_LLWU_PIN (14)
#define PIN_SW_RESET_LLWU_WAKEUP_TYPE kLLWU_ExternalPinFallingEdge
#define PIN_SW_RESET_PORT_WAKEUP_TYPE kPORT_InterruptFallingEdge

// WAKE_ON_EDGE PTC4
#define PIN_WAKE_ON_EDGE_PORT PORTC
#define PIN_WAKE_ON_EDGE_GPIO PTC
#define PIN_WAKE_ON_EDGE_BIT (4)
#define PIN_WAKE_ON_EDGE (1<<PIN_WAKE_ON_EDGE_BIT)
#define PIN_WAKE_ON_EDGE_LLWU_PIN (8)
#define PIN_WAKE_ON_EDGE_LLWU_WAKEUP_TYPE kLLWU_ExternalPinFallingEdge
#define PIN_WAKE_ON_EDGE_PORT_WAKEUP_TYPE kPORT_InterruptEitherEdge

// Power LEDs

// Yellow LED PTB0, configured as HID/MSC/CDC LEDs

// Red Spare LED PTD7
#define PIN_RED_LED_PORT PORTD
#define PIN_RED_LED_GPIO PTD
#define PIN_RED_LED_BIT (7)
#define PIN_RED_LED (1<<PIN_RED_LED_BIT)


// define the reset button presses
#define RESET_SHORT_PRESS 10 // x 30ms debounce time = 300ms
#define RESET_MID_PRESS 80 // x 30ms debounce time = 2400ms
#define RESET_LONG_PRESS 120 // x 30ms debounce time = 3600ms
#define RESET_MAX_LENGTH_PRESS RESET_LONG_PRESS

// BOARD REV ID
#define PIN_BOARD_REV_ID_PORT PORTD
#define PIN_BOARD_REV_ID_GPIO PTD
#define PIN_BOARD_REV_ID_BIT (6)
#define PIN_BOARD_REV_ID (1<<PIN_BOARD_REV_ID_BIT)
#define PIN_BOARD_REV_ID_ADC_CH (7)
#define PIN_BOARD_REV_ID_ADC_MUX (1)

// COMBINED_SENSOR_INT PTA1
#define COMBINED_SENSOR_INT_PORT PORTA
#define COMBINED_SENSOR_INT_GPIO GPIOA
#define COMBINED_SENSOR_INT_PIN (1)

// Connected LED Not available

// Target Running LED Not available

// UART
#define UART_PORT PORTA
#define UART_NUM (1)
// RX PTA18
#define PIN_UART_RX_GPIO PTA
#define PIN_UART_RX_BIT (18)
#define PIN_UART_RX (1<<PIN_UART_RX_BIT)
#define PIN_UART_RX_MUX_ALT (3)
// TX PTA19
#define PIN_UART_TX_GPIO PTA
#define PIN_UART_TX_BIT (19)
#define PIN_UART_TX (1<<PIN_UART_TX_BIT)
#define PIN_UART_TX_MUX_ALT (3)

#define UART LPUART1
#define UART_RX_TX_IRQn LPUART1_IRQn
#define UART_RX_TX_IRQHandler LPUART1_IRQHandler

#endif
Loading