Merge pull request #7345 from dhalbert/mimx-fix-build

redo pin never resetting for mimxrt10xx
This commit is contained in:
Scott Shawcroft 2022-12-15 12:21:21 -08:00 committed by GitHub
commit c6ea3e803a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 218 additions and 166 deletions

View File

@ -26,21 +26,23 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// SWD Pins
common_hal_never_reset_pin(&pin_GPIO_AD_13);// SWDIO
common_hal_never_reset_pin(&pin_GPIO_AD_12);// SWCLK
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_AD_13,// SWDIO
&pin_GPIO_AD_12,// SWCLK
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_12);
common_hal_never_reset_pin(&pin_GPIO_SD_11);
common_hal_never_reset_pin(&pin_GPIO_SD_10);
common_hal_never_reset_pin(&pin_GPIO_SD_09);
common_hal_never_reset_pin(&pin_GPIO_SD_08);
common_hal_never_reset_pin(&pin_GPIO_SD_07);
common_hal_never_reset_pin(&pin_GPIO_SD_06);
}
&pin_GPIO_SD_12,
&pin_GPIO_SD_11,
&pin_GPIO_SD_10,
&pin_GPIO_SD_09,
&pin_GPIO_SD_08,
&pin_GPIO_SD_07,
&pin_GPIO_SD_06,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -26,23 +26,23 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// SWD Pins
common_hal_never_reset_pin(&pin_GPIO_AD_13);// SWDIO
common_hal_never_reset_pin(&pin_GPIO_AD_12);// SWCLK
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_AD_13,// SWDIO
&pin_GPIO_AD_12,// SWCLK
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_12);
common_hal_never_reset_pin(&pin_GPIO_SD_11);
common_hal_never_reset_pin(&pin_GPIO_SD_10);
common_hal_never_reset_pin(&pin_GPIO_SD_09);
common_hal_never_reset_pin(&pin_GPIO_SD_08);
common_hal_never_reset_pin(&pin_GPIO_SD_07);
common_hal_never_reset_pin(&pin_GPIO_SD_06);
}
&pin_GPIO_SD_12,
&pin_GPIO_SD_11,
&pin_GPIO_SD_10,
&pin_GPIO_SD_09,
&pin_GPIO_SD_08,
&pin_GPIO_SD_07,
&pin_GPIO_SD_06,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -26,22 +26,23 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
// SWD Pins
common_hal_never_reset_pin(&pin_GPIO_AD_B0_06);// SWDIO
common_hal_never_reset_pin(&pin_GPIO_AD_B0_07);// SWCLK
&pin_GPIO_AD_B0_06,// SWDIO
&pin_GPIO_AD_B0_07,// SWCLK
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_B1_06);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_07);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_08);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_09);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_10);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_11);
}
&pin_GPIO_SD_B1_06,
&pin_GPIO_SD_B1_07,
&pin_GPIO_SD_B1_08,
&pin_GPIO_SD_B1_09,
&pin_GPIO_SD_B1_10,
&pin_GPIO_SD_B1_11,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -26,25 +26,25 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// SWD Pins
common_hal_never_reset_pin(&pin_GPIO_AD_13); // SWDIO
common_hal_never_reset_pin(&pin_GPIO_AD_12); // SWCLK
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_AD_13, // SWDIO
&pin_GPIO_AD_12, // SWCLK
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_12);
common_hal_never_reset_pin(&pin_GPIO_SD_11);
common_hal_never_reset_pin(&pin_GPIO_SD_10);
common_hal_never_reset_pin(&pin_GPIO_SD_09);
common_hal_never_reset_pin(&pin_GPIO_SD_08);
common_hal_never_reset_pin(&pin_GPIO_SD_07);
common_hal_never_reset_pin(&pin_GPIO_SD_06);
&pin_GPIO_SD_12,
&pin_GPIO_SD_11,
&pin_GPIO_SD_10,
&pin_GPIO_SD_09,
&pin_GPIO_SD_08,
&pin_GPIO_SD_07,
&pin_GPIO_SD_06,
// USB Pins
common_hal_never_reset_pin(&pin_GPIO_12);
common_hal_never_reset_pin(&pin_GPIO_13);
}
&pin_GPIO_12,
&pin_GPIO_13,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -26,26 +26,27 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
// SWD Pins
common_hal_never_reset_pin(&pin_GPIO_AD_B0_00);// SWDIO
common_hal_never_reset_pin(&pin_GPIO_AD_B0_01);// SWCLK
&pin_GPIO_AD_B0_00,// SWDIO
&pin_GPIO_AD_B0_01,// SWCLK
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_B1_06);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_07);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_08);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_09);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_10);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_11);
&pin_GPIO_SD_B1_06,
&pin_GPIO_SD_B1_07,
&pin_GPIO_SD_B1_08,
&pin_GPIO_SD_B1_09,
&pin_GPIO_SD_B1_10,
&pin_GPIO_SD_B1_11,
// USB Pins
common_hal_never_reset_pin(&pin_GPIO_AD_B1_11);
common_hal_never_reset_pin(&pin_GPIO_AD_B1_12);
}
&pin_GPIO_AD_B1_11,
&pin_GPIO_AD_B1_12,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -26,30 +26,33 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
// SWD Pins
common_hal_never_reset_pin(&pin_GPIO_AD_B0_06);// SWDIO
common_hal_never_reset_pin(&pin_GPIO_AD_B0_07);// SWCLK
&pin_GPIO_AD_B0_06, // SWDIO
&pin_GPIO_AD_B0_07, // SWCLK
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_B1_00);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_01);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_02);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_03);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_04);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_05);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_06);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_07);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_08);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_09);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_10);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_11);
&pin_GPIO_SD_B1_00,
&pin_GPIO_SD_B1_01,
&pin_GPIO_SD_B1_02,
&pin_GPIO_SD_B1_03,
&pin_GPIO_SD_B1_04,
&pin_GPIO_SD_B1_05,
&pin_GPIO_SD_B1_06,
&pin_GPIO_SD_B1_07,
&pin_GPIO_SD_B1_08,
&pin_GPIO_SD_B1_09,
&pin_GPIO_SD_B1_10,
&pin_GPIO_SD_B1_11,
// USB Pins
common_hal_never_reset_pin(&pin_GPIO_AD_B0_01);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_03);
}
&pin_GPIO_AD_B0_01,
&pin_GPIO_AD_B0_03,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -26,23 +26,24 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
// SWD Pins
common_hal_never_reset_pin(&pin_GPIO_AD_13);// SWDIO
common_hal_never_reset_pin(&pin_GPIO_AD_12);// SWCLK
&pin_GPIO_AD_13,// SWDIO
&pin_GPIO_AD_12,// SWCLK
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_12);
common_hal_never_reset_pin(&pin_GPIO_SD_11);
common_hal_never_reset_pin(&pin_GPIO_SD_10);
common_hal_never_reset_pin(&pin_GPIO_SD_09);
common_hal_never_reset_pin(&pin_GPIO_SD_08);
common_hal_never_reset_pin(&pin_GPIO_SD_07);
common_hal_never_reset_pin(&pin_GPIO_SD_06);
}
&pin_GPIO_SD_12,
&pin_GPIO_SD_11,
&pin_GPIO_SD_10,
&pin_GPIO_SD_09,
&pin_GPIO_SD_08,
&pin_GPIO_SD_07,
&pin_GPIO_SD_06,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -26,31 +26,31 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_B1_06);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_07);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_08);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_09);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_10);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_11);
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_SD_B1_06,
&pin_GPIO_SD_B1_07,
&pin_GPIO_SD_B1_08,
&pin_GPIO_SD_B1_09,
&pin_GPIO_SD_B1_10,
&pin_GPIO_SD_B1_11,
// FLEX flash 2
common_hal_never_reset_pin(&pin_GPIO_AD_B0_04);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_06);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_07);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_08);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_09);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_10);
common_hal_never_reset_pin(&pin_GPIO_EMC_01);
common_hal_never_reset_pin(&pin_GPIO_B0_13);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_11);
&pin_GPIO_AD_B0_04,
&pin_GPIO_AD_B0_06,
&pin_GPIO_AD_B0_07,
&pin_GPIO_AD_B0_08,
&pin_GPIO_AD_B0_09,
&pin_GPIO_AD_B0_10,
&pin_GPIO_EMC_01,
&pin_GPIO_B0_13,
&pin_GPIO_AD_B0_11,
// Data strobe needs protection despite being grounded
common_hal_never_reset_pin(&pin_GPIO_SD_B1_05);
}
&pin_GPIO_SD_B1_05,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -26,31 +26,32 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_B1_06);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_07);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_08);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_09);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_10);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_11);
&pin_GPIO_SD_B1_06,
&pin_GPIO_SD_B1_07,
&pin_GPIO_SD_B1_08,
&pin_GPIO_SD_B1_09,
&pin_GPIO_SD_B1_10,
&pin_GPIO_SD_B1_11,
// FLEX flash 2
common_hal_never_reset_pin(&pin_GPIO_AD_B0_04);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_06);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_07);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_08);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_09);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_10);
common_hal_never_reset_pin(&pin_GPIO_EMC_01);
common_hal_never_reset_pin(&pin_GPIO_B0_13);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_11);
&pin_GPIO_AD_B0_04,
&pin_GPIO_AD_B0_06,
&pin_GPIO_AD_B0_07,
&pin_GPIO_AD_B0_08,
&pin_GPIO_AD_B0_09,
&pin_GPIO_AD_B0_10,
&pin_GPIO_EMC_01,
&pin_GPIO_B0_13,
&pin_GPIO_AD_B0_11,
// Data strobe needs protection despite being grounded
common_hal_never_reset_pin(&pin_GPIO_SD_B1_05);
}
&pin_GPIO_SD_B1_05,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -26,29 +26,32 @@
*/
#include "supervisor/board.h"
#include "boards/flash_config.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// These pins should never ever be reset; doing so could interfere with basic operation.
// Used in common-hal/microcontroller/Pin.c
const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
// FLEX flash
common_hal_never_reset_pin(&pin_GPIO_SD_B1_06);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_07);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_08);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_09);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_10);
common_hal_never_reset_pin(&pin_GPIO_SD_B1_11);
&pin_GPIO_SD_B1_06,
&pin_GPIO_SD_B1_07,
&pin_GPIO_SD_B1_08,
&pin_GPIO_SD_B1_09,
&pin_GPIO_SD_B1_10,
&pin_GPIO_SD_B1_11,
// FLEX flash 2
common_hal_never_reset_pin(&pin_GPIO_AD_B0_04);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_06);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_07);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_08);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_09);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_10);
common_hal_never_reset_pin(&pin_GPIO_EMC_01);
common_hal_never_reset_pin(&pin_GPIO_B0_13);
common_hal_never_reset_pin(&pin_GPIO_AD_B0_11);
&pin_GPIO_AD_B0_04,
&pin_GPIO_AD_B0_06,
&pin_GPIO_AD_B0_07,
&pin_GPIO_AD_B0_08,
&pin_GPIO_AD_B0_09,
&pin_GPIO_AD_B0_10,
&pin_GPIO_EMC_01,
&pin_GPIO_B0_13,
&pin_GPIO_AD_B0_11,
// Data strobe needs protection despite being grounded
common_hal_never_reset_pin(&pin_GPIO_SD_B1_05);
}
&pin_GPIO_SD_B1_05,
NULL, // Must end in NULL.
};
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

View File

@ -31,6 +31,22 @@
STATIC bool claimed_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT];
STATIC bool never_reset_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT];
// Default is that no pins are forbidden to reset.
MP_WEAK const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
NULL,
};
STATIC bool _reset_forbidden(const mcu_pin_obj_t *pin) {
const mcu_pin_obj_t **forbidden_pin = &mimxrt10xx_reset_forbidden_pins[0];
while (*forbidden_pin) {
if (pin == *forbidden_pin) {
return true;
}
forbidden_pin++;
}
return false;
}
// There are two numbering systems used here:
// IOMUXC index, used for iterating through pins and accessing reset information,
// and GPIO port and number, used to store claimed and reset tagging. The two number
@ -44,17 +60,31 @@ void reset_all_pins(void) {
if (never_reset_pins[pin->mux_idx]) {
continue;
}
*(uint32_t *)pin->mux_reg = pin->mux_reset;
*(uint32_t *)pin->cfg_reg = pin->pad_reset;
common_hal_reset_pin(pin);
}
}
MP_WEAK bool mimxrt10xx_board_reset_pin_number(const mcu_pin_obj_t *pin) {
return false;
}
// Since i.MX pins need extra register and reset information to reset properly,
// resetting pins by number alone has been removed.
void common_hal_reset_pin(const mcu_pin_obj_t *pin) {
return;
if (pin == NULL) {
return;
}
if (_reset_forbidden(pin)) {
return;
}
// Give the board a chance to reset the pin in a particular way, or not reset it at all.
if (mimxrt10xx_board_reset_pin_number(pin)) {
return;
}
never_reset_pins[pin->mux_idx] = false;
claimed_pins[pin->mux_idx] = false;
*(uint32_t *)pin->mux_reg = pin->mux_reset;

View File

@ -35,4 +35,14 @@
void reset_all_pins(void);
void claim_pin(const mcu_pin_obj_t *pin);
// List of pins that should never be reset.
extern const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[];
// Allow the board to reset a pin in a board-specific way. This can be used
// for LEDs or enable pins to put them in a state beside the default pull-up,
// or to simply not reset the pin at all.
// Return true to indicate that the pin was handled in a special way. Returning false will lead to
// the port-default reset behavior.
extern bool mimxrt10xx_board_reset_pin_number(const mcu_pin_obj_t *pin);
#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_MICROCONTROLLER_PIN_H