Skip to content

Commit

Permalink
Full UART support for RPI
Browse files Browse the repository at this point in the history
This adds PL011 UART support which is more plentiful.

It also:
* Fixes PI4 build by including .dtb files on the SD card.
* Enables the activity LED as the status LED on PI4 and CM4 I/O.
* Adds that LED as board.LED.

Fixes adafruit#5650 and progress on adafruit#5629
  • Loading branch information
tannewt authored and gamblor21 committed Dec 13, 2021
1 parent dfc49bf commit c53aacb
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 54 deletions.
1 change: 1 addition & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "supervisor/shared/safe_mode.h"
#include "supervisor/shared/stack.h"
#include "supervisor/shared/status_leds.h"
#include "supervisor/shared/tick.h"
#include "supervisor/shared/traceback.h"
#include "supervisor/shared/translate.h"
#include "supervisor/shared/workflow.h"
Expand Down
2 changes: 1 addition & 1 deletion ports/broadcom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ $(BUILD)/firmware.disk.img.zip: $(BUILD)/kernel8.img
$(Q)parted -s $(BUILD)/circuitpython-disk.img mkpart primary fat32 0% 100%
$(Q)mkfs.fat -F 32 -n BOOT --offset=2048 $(BUILD)/circuitpython-disk.img

$(Q)mcopy -i $(BUILD)/circuitpython-disk.img@@1M config.txt firmware/bootcode.bin firmware/fixup* firmware/start* ::
$(Q)mcopy -i $(BUILD)/circuitpython-disk.img@@1M config.txt firmware/bootcode.bin firmware/fixup* firmware/start* firmware/*.dtb ::
$(Q)mcopy -i $(BUILD)/circuitpython-disk.img@@1M $(BUILD)/kernel8.img ::
$(Q)zip $@ $(BUILD)/circuitpython-disk.img
$(Q)rm $(BUILD)/circuitpython-disk.img
Expand Down
2 changes: 2 additions & 0 deletions ports/broadcom/boards/raspberrypi_cm4io/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2)

#define MICROPY_HW_LED_STATUS (&pin_GPIO42)
2 changes: 2 additions & 0 deletions ports/broadcom/boards/raspberrypi_cm4io/pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) },

{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO42) },

{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
};
Expand Down
2 changes: 2 additions & 0 deletions ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2)

#define MICROPY_HW_LED_STATUS (&pin_GPIO42)
2 changes: 1 addition & 1 deletion ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ USB_PID = 0xF001
USB_PRODUCT = "Raspberry Pi 4B"
USB_MANUFACTURER = "Raspberry Pi"

CHIP_VARIANT = bcm2711
CHIP_VARIANT = "bcm2711"
2 changes: 2 additions & 0 deletions ports/broadcom/boards/raspberrypi_pi4b/pins.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) },
{ MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) },

{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO42) },

{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
};
Expand Down
3 changes: 2 additions & 1 deletion ports/broadcom/common-hal/busio/I2C.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
uint8_t sda_alt = 0;
for (scl_alt = 0; scl_alt < 6; scl_alt++) {
if (scl->functions[scl_alt].type != PIN_FUNCTION_I2C ||
i2c_in_use[scl->functions[scl_alt].index]) {
i2c_in_use[scl->functions[scl_alt].index] ||
scl->functions[scl_alt].function != I2C_FUNCTION_SCL) {
continue;
}
for (sda_alt = 0; sda_alt < 6; sda_alt++) {
Expand Down
Loading

0 comments on commit c53aacb

Please sign in to comment.