Skip to content

Commit

Permalink
Merge pull request #1271 from tannewt/rpi_zero
Browse files Browse the repository at this point in the history
Add Raspberry Pi Zero W and Zero 2 W
  • Loading branch information
hathach committed Jan 6, 2022
2 parents 868948f + bed8913 commit 77b4234
Show file tree
Hide file tree
Showing 100 changed files with 482 additions and 121 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
family:
# Alphabetical order
- 'raspberrypi4'
- 'broadcom_64bit'
steps:
- name: Setup Python
uses: actions/setup-python@v2
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
matrix:
family:
# Alphabetical order
- 'broadcom_32bit'
- 'imxrt'
- 'lpc15'
- 'lpc18'
Expand Down Expand Up @@ -114,7 +115,7 @@ jobs:
done
# ---------------------------------------
# Build all no-family (opharned) boards
# Build all no-family (orphaned) boards
# ---------------------------------------
build-board:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ cov-int
# cppcheck build directories
*-build-dir
/_bin/
__pycache__

Empty file.
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions examples/device/audio_4_channel_mic/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mcu:SAMD11
mcu:SAME5X
mcu:SAMG
Empty file.
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions examples/device/audio_test/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mcu:SAMD11
mcu:SAME5X
mcu:SAMG
Empty file.
1 change: 1 addition & 0 deletions examples/device/cdc_msc/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mcu:SAMD11
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions examples/device/cdc_msc_freertos/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mcu:CXD56
mcu:MSP430x5xx
mcu:SAMD11
mcu:VALENTYUSB_EPTRI
mcu:MKL25ZXX
mcu:RP2040
mcu:SAMX7X
mcu:GD32VF103
family:broadcom_64bit
family:broadcom_32bit
4 changes: 0 additions & 4 deletions examples/device/dfu/.skip.MCU_TM4C123

This file was deleted.

2 changes: 2 additions & 0 deletions examples/device/dfu/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mcu:TM4C123
mcu:BCM2835
Empty file.
1 change: 1 addition & 0 deletions examples/device/dynamic_configuration/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mcu:SAMD11
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
9 changes: 9 additions & 0 deletions examples/device/hid_composite_freertos/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mcu:CXD56
mcu:MSP430x5xx
mcu:SAMD11
mcu:VALENTYUSB_EPTRI
mcu:RP2040
mcu:SAMX7X
mcu:GD32VF103
family:broadcom_64bit
family:broadcom_32bit
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions examples/device/msc_dual_lun/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mcu:SAMD11
mcu:MKL25ZXX
1 change: 0 additions & 1 deletion examples/device/net_lwip_webserver/.skip.MCU_BCM2711

This file was deleted.

Empty file.
Empty file.
Empty file.
1 change: 0 additions & 1 deletion examples/device/net_lwip_webserver/.skip.MCU_MSP430x5xx

This file was deleted.

Empty file.
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions examples/device/net_lwip_webserver/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mcu:LPC11UXX
mcu:LPC13XX
mcu:MSP430x5xx
mcu:NUC121
mcu:SAMD11
mcu:STM32L0
mcu:MKL25ZXX
family:broadcom_64bit
family:broadcom_32bit
board:curiosity_nano
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions examples/device/uac2_headset/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mcu:LPC11UXX
mcu:LPC13XX
mcu:NUC121
mcu:SAMD11
mcu:SAME5X
mcu:SAMG
1 change: 1 addition & 0 deletions examples/device/usbtmc/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mcu:BCM2835
1 change: 0 additions & 1 deletion examples/device/video_capture/.skip.MCU_MSP430x5xx

This file was deleted.

Empty file.
2 changes: 2 additions & 0 deletions examples/device/video_capture/skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mcu:MSP430x5xx
mcu:SAMD11
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions examples/host/cdc_msc_hid/only.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mcu:LPC175X_6X
mcu:LPC177X_8X
mcu:LPC18XX
mcu:LPC40XX
mcu:LPC43XX
mcu:MIMXRT10XX
mcu:RP2040
mcu:MSP432E4
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions examples/host/hid_controller/only.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mcu:LPC175X_6X
mcu:LPC177X_8X
mcu:LPC18XX
mcu:LPC40XX
mcu:LPC43XX
mcu:MIMXRT10XX
mcu:RP2040
mcu:MSP432E4
5 changes: 4 additions & 1 deletion hw/bsp/board_mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

//--------------------------------------------------------------------+
// Low Level MCU header include. TinyUSB stack and example should be
// platform independent and mostly doens't need to include this file.
// platform independent and mostly doesn't need to include this file.
// However there are still certain situation where this file is needed:
// - FreeRTOSConfig.h to set up correct clock and NVIC interrupts for ARM Cortex
// - SWO logging for Cortex M with ITM_SendChar() / ITM_ReceiveChar()
Expand Down Expand Up @@ -146,6 +146,9 @@
#elif CFG_TUSB_MCU == OPT_MCU_TM4C123
#include "TM4C123.h"

#elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837)
// no header needed

#else
#error "Missing MCU header"
#endif
Expand Down
5 changes: 5 additions & 0 deletions hw/bsp/broadcom_32bit/boards/raspberrypi_zero_w/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CFLAGS += -mcpu=arm1176jzf-s \
-DBCM_VERSION=2835 \
-DCFG_TUSB_MCU=OPT_MCU_BCM2835

SUFFIX =
32 changes: 22 additions & 10 deletions hw/bsp/raspberrypi4/family.c → hw/bsp/broadcom_32bit/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
#include "bsp/board.h"
#include "board.h"

#include "broadcom/cpu.h"
#include "broadcom/gpio.h"
#include "broadcom/interrupts.h"
#include "broadcom/io.h"
#include "broadcom/mmu.h"
#include "broadcom/caches.h"
#include "broadcom/vcmailbox.h"
Expand All @@ -37,9 +38,8 @@
#define LED_PIN 18
#define LED_STATE_ON 1

// Button
#define BUTTON_PIN 16
#define BUTTON_STATE_ACTIVE 0
// UART TX
#define UART_TX_PIN 14

//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
Expand All @@ -62,14 +62,26 @@ void board_init(void)
init_caches();

// LED
gpio_initOutputPinWithPullNone(LED_PIN);
gpio_set_function(LED_PIN, GPIO_FUNCTION_OUTPUT);
gpio_set_pull(LED_PIN, BP_PULL_NONE);
board_led_write(true);

// Button
// TODO

// Uart
uart_init();
COMPLETE_MEMORY_READS;
AUX->ENABLES_b.UART_1 = true;

UART1->IER = 0;
UART1->CNTL = 0;
UART1->LCR_b.DATA_SIZE = UART1_LCR_DATA_SIZE_MODE_8BIT;
UART1->MCR = 0;
UART1->IER = 0;

uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE);
UART1->BAUD = ((source_clock / (115200 * 8)) - 1);
UART1->CNTL |= UART1_CNTL_TX_ENABLE_Msk;
COMPLETE_MEMORY_READS;

gpio_set_function(UART_TX_PIN, GPIO_FUNCTION_ALT5);

// Turn on USB peripheral.
vcmailbox_set_power_state(VCMAILBOX_DEVICE_USB_HCD, true);
Expand All @@ -87,7 +99,7 @@ void board_init(void)

void board_led_write(bool state)
{
gpio_setPinOutputBool(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
gpio_set_value(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
}

uint32_t board_button_read(void)
Expand Down
46 changes: 46 additions & 0 deletions hw/bsp/broadcom_32bit/family.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
MCU_DIR = hw/mcu/broadcom
DEPS_SUBMODULES += $(MCU_DIR)

include $(TOP)/$(BOARD_PATH)/board.mk

CFLAGS += \
-Wall \
-O0 \
-ffreestanding \
-nostdlib \
-nostartfiles \
-mgeneral-regs-only \
-fno-exceptions \
-std=c17

CROSS_COMPILE = arm-none-eabi-

# mcu driver cause following warnings
CFLAGS += -Wno-error=cast-qual

SRC_C += \
src/portable/synopsys/dwc2/dcd_dwc2.c \
$(MCU_DIR)/broadcom/gen/interrupt_handlers.c \
$(MCU_DIR)/broadcom/gpio.c \
$(MCU_DIR)/broadcom/interrupts.c \
$(MCU_DIR)/broadcom/mmu.c \
$(MCU_DIR)/broadcom/caches.c \
$(MCU_DIR)/broadcom/vcmailbox.c

SKIP_NANOLIB = 1

LD_FILE = $(MCU_DIR)/broadcom/link$(SUFFIX).ld

INC += \
$(TOP)/$(BOARD_PATH) \
$(TOP)/$(MCU_DIR)

SRC_S += $(MCU_DIR)/broadcom/boot$(SUFFIX).S

$(BUILD)/kernel$(SUFFIX).img: $(BUILD)/$(PROJECT).elf
$(OBJCOPY) -O binary $^ $@

# Copy to kernel to netboot drive or SD card
# Change destinaation to fit your need
flash: $(BUILD)/kernel$(SUFFIX).img
@$(CP) $< /home/$(USER)/Documents/code/pi_tinyusb/boot_cpy
38 changes: 38 additions & 0 deletions hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020, Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/

#ifndef BOARD_H_
#define BOARD_H_

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

#endif /* BOARD_H_ */
3 changes: 3 additions & 0 deletions hw/bsp/broadcom_64bit/boards/raspberrypi_cm4/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CFLAGS += -mcpu=cortex-a72 \
-DBCM_VERSION=2711 \
-DCFG_TUSB_MCU=OPT_MCU_BCM2711
38 changes: 38 additions & 0 deletions hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020, Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This file is part of the TinyUSB stack.
*/

#ifndef BOARD_H_
#define BOARD_H_

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

#endif /* BOARD_H_ */
3 changes: 3 additions & 0 deletions hw/bsp/broadcom_64bit/boards/raspberrypi_zero2w/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CFLAGS += -mcpu=cortex-a53 \
-DBCM_VERSION=2837 \
-DCFG_TUSB_MCU=OPT_MCU_BCM2837

0 comments on commit 77b4234

Please sign in to comment.