Skip to content

Commit

Permalink
Merge pull request #297 from raspberrypi/develop-1.1.1
Browse files Browse the repository at this point in the history
Develop 1.1.1
  • Loading branch information
kilograham committed Apr 1, 2021
2 parents fc10a97 + 7f2f186 commit 02b98e5
Show file tree
Hide file tree
Showing 35 changed files with 306 additions and 110 deletions.
3 changes: 1 addition & 2 deletions cmake/pico_pre_load_toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# PICO_CMAKE_CONFIG: PICO_TOOLCHAIN_PATH, Path to search for compiler, default=none (i.e. search system paths), group=build
# Set your compiler path here if it's not in the PATH environment variable.
set(PICO_TOOLCHAIN_PATH "" CACHE INTERNAL "")
set(PICO_TOOLCHAIN_PATH "${PICO_TOOLCHAIN_PATH}" CACHE INTERNAL "")

# Set a default build type if none was specified
set(default_build_type "Release")
Expand Down
5 changes: 3 additions & 2 deletions cmake/preload/toolchains/pico_arm_gcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)

# todo move to platform/Generix-xxx
set(ARM_GCC_COMMON_FLAGS " -march=armv6-m -mcpu=cortex-m0plus -mthumb")
#set(ARM_GCC_COMMON_FLAGS " -mcpu=cortex-m0plus -mthumb")

# on ARM -mcpu should not be mixed with -march
set(ARM_GCC_COMMON_FLAGS " -mcpu=cortex-m0plus -mthumb")
foreach(LANG IN ITEMS C CXX ASM)
set(CMAKE_${LANG}_FLAGS_INIT "${ARM_GCC_COMMON_FLAGS}")
if (PICO_DEOPTIMIZED_DEBUG)
Expand Down
22 changes: 15 additions & 7 deletions pico_sdk_version.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, pico_base
# PICO_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
set(PICO_SDK_VERSION_MAJOR 1)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, pico_base
# PICO_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, pico_base
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
set(PICO_SDK_VERSION_MINOR 1)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, pico_base
# PICO_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, pico_base
set(PICO_SDK_VERSION_REVISION 0)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
set(PICO_SDK_VERSION_REVISION 1)
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
set(PICO_SDK_VERSION_PRE_RELEASE_ID develop)

# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
# PICO_CONFIG: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
set(PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}")

if (PICO_SDK_VERSION_PRE_RELEASE_ID)
set(PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_STRING}-${PICO_SDK_VERSION_PRE_RELEASE_ID}")
endif()
8 changes: 6 additions & 2 deletions src/boards/include/boards/adafruit_feather_rp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@
#endif

//------------- FLASH -------------//

// Use slower generic flash access
#define PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#define PICO_FLASH_SPI_CLKDIV 4
#endif

#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif

// All boards have B1 RP2040
Expand Down
3 changes: 3 additions & 0 deletions src/boards/include/boards/adafruit_itsybitsy_rp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
#endif

//------------- FLASH -------------//

#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/boards/include/boards/adafruit_qtpy_rp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
#endif

//------------- FLASH -------------//

#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/boards/include/boards/pico.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@

// --- FLASH ---

#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/boards/include/boards/pimoroni_keybow2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@
#define KEYBOW2040_SW15_PIN 6
#endif

#ifndef KEYBOW2040_NUM_SWITCHES
#ifndef KEYBOW2040_NUM_SWITCHES_PINS
#define KEYBOW2040_NUM_SWITCHES_PINS 16
#endif

#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/boards/include/boards/pimoroni_picosystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
#define PICO_DEFAULT_LED_PIN_INVERTED 1
#endif

#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/boards/include/boards/pimoroni_tiny2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
#define PICO_DEFAULT_LED_PIN_INVERTED 1
#endif

#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/boards/include/boards/sparkfun_micromod.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 0
#define
#endif

#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 0
Expand Down Expand Up @@ -47,6 +47,8 @@
#endif

// spi flash
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/boards/include/boards/sparkfun_promicro.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#define PICO_DEFAULT_I2C_SCL_PIN 17
#endif

#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/boards/include/boards/sparkfun_thingplus.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
#endif

// spi flash

#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
Expand Down
6 changes: 4 additions & 2 deletions src/boards/include/boards/vgaboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#define VGABOARD_VGA_COLOR_PIN_BASE 0
#define VGABOARD_VGA_SYNC_PIN_BASE 16

// Note DAT2/3 are shared with UART TX/RX (pull jumpers off header to access
// UART pins and disconnect SD DAT2/3)
// Note DAT1/2 are shared with UART TX/RX (pull jumpers off header to access
// UART pins and disconnect SD DAT1/2)
#define VGABOARD_SD_CLK_PIN 5
#define VGABOARD_SD_CMD_PIN 18
#define VGABOARD_SD_DAT0_PIN 19
Expand Down Expand Up @@ -57,10 +57,12 @@
#define PICO_SD_CMD_PIN VGABOARD_SD_CMD_PIN
#define PICO_SD_DAT0_PIN VGABOARD_SD_DAT0_PIN

// 1 or 4
#ifndef PICO_SD_DAT_PIN_COUNT
#define PICO_SD_DAT_PIN_COUNT 4
#endif

// 1 or -1
#define PICO_SD_DAT_PIN_INCREMENT 1

#define PICO_AUDIO_I2S_DATA_PIN VGABOARD_I2S_DIN_PIN
Expand Down
8 changes: 4 additions & 4 deletions src/common/pico_base/include/pico/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typedef unsigned int uint;
\see update_us_since_boot()
\ingroup timestamp
*/
#ifndef NDEBUG
#ifdef NDEBUG
typedef uint64_t absolute_time_t;
#else
typedef struct {
Expand All @@ -40,7 +40,7 @@ typedef struct {
* \ingroup timestamp
*/
static inline uint64_t to_us_since_boot(absolute_time_t t) {
#ifndef NDEBUG
#ifdef NDEBUG
return t;
#else
return t._private_us_since_boot;
Expand All @@ -55,15 +55,15 @@ static inline uint64_t to_us_since_boot(absolute_time_t t) {
* \ingroup timestamp
*/
static inline void update_us_since_boot(absolute_time_t *t, uint64_t us_since_boot) {
#ifndef NDEBUG
#ifdef NDEBUG
*t = us_since_boot;
#else
assert(us_since_boot <= INT64_MAX);
t->_private_us_since_boot = us_since_boot;
#endif
}

#ifndef NDEBUG
#ifdef NDEBUG
#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = value
#else
#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = {value}
Expand Down
9 changes: 8 additions & 1 deletion src/common/pico_util/include/pico/util/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
* \ingroup pico_util
*/

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
spin_lock_t *lock;
uint8_t *data;
Expand Down Expand Up @@ -69,7 +73,7 @@ void queue_free(queue_t *q);
static inline uint queue_get_level_unsafe(queue_t *q) {
int32_t rc = (int32_t)q->wptr - (int32_t)q->rptr;
if (rc < 0) {
rc += + q->element_count + 1;
rc += q->element_count + 1;
}
return (uint)rc;
}
Expand Down Expand Up @@ -181,4 +185,7 @@ void queue_remove_blocking(queue_t *q, void *data);
*/
void queue_peek_blocking(queue_t *q, void *data);

#ifdef __cplusplus
}
#endif
#endif
7 changes: 7 additions & 0 deletions src/host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ pico_add_subdirectory(pico_stdlib)
pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})

macro(pico_set_float_implementation TARGET IMPL)
# ignore
endmacro()

macro(pico_set_double_implementation TARGET IMPL)
# ignore
endmacro()

macro(pico_set_binary_type TARGET IMPL)
# ignore
endmacro()

macro(pico_set_boot_stage2 TARGET IMPL)
# ignore
endmacro()

set(PICO_HOST_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "")
Expand Down
44 changes: 33 additions & 11 deletions src/rp2_common/boot_stage2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
# PICO_CMAKE_CONFIG: PICO_DEFAULT_BOOT_STAGE2_FILE, Default stage2 file to use unless overridden by pico_set_boot_stage2 on the TARGET, type=bool, default=.../boot2_w25q080.S, group=build
if (NOT PICO_DEFAULT_BOOT_STAGE2_FILE)
set(PICO_DEFAULT_BOOT_STAGE2_FILE "${CMAKE_CURRENT_LIST_DIR}/boot2_w25q080.S")
# PICO_CMAKE_CONFIG: PICO_DEFAULT_BOOT_STAGE2_FILE, Default stage2 file to use unless overridden by pico_set_boot_stage2 on the TARGET; this setting is useful when explicitly setting the default build from a per board CMake file, group=build
# PICO_CMAKE_CONFIG: PICO_DEFAULT_BOOT_STAGE2, Simpler alternative to specifying PICO_DEFAULT_BOOT_STAGE2_FILE where the file is src/boards/{PICO_DEFAULT_BOOT_STAGE2_FILE}.S, default=compile_time_choice, group=build
if (DEFINED ENV{PICO_DEFAULT_BOOT_STAGE2_FILE})
set(PICO_DEFAULT_BOOT_STAGE2_FILE $ENV{PICO_DEFAULT_BOOT_STAGE2_FILE})
message("Using PICO_DEFAULT_BOOT_STAGE2_FILE from environment ('${PICO_DEFAULT_BOOT_STAGE2_FILE}')")
endif()

set(PICO_DEFAULT_BOOT_STAGE2_FILE "${PICO_DEFAULT_BOOT_STAGE2_FILE}" CACHE STRING "boot_stage2 source file" FORCE)

set(PICO_BOOT_STAGE2_COMPILE_TIME_CHOICE_NAME compile_time_choice) # local var
if (NOT PICO_DEFAULT_BOOT_STAGE2_FILE)
if (DEFINED ENV{PICO_DEFAULT_BOOT_STAGE2})
set(PICO_DEFAULT_BOOT_STAGE2 $ENV{PICO_DEFAULT_BOOT_STAGE2})
message("Using PICO_DEFAULT_BOOT_STAGE2 from environment ('${PICO_DEFAULT_BOOT_STAGE2}')")
endif()
if (NOT DEFINED PICO_DEFAULT_BOOT_STAGE2)
set(PICO_DEFAULT_BOOT_STAGE2 ${PICO_BOOT_STAGE2_COMPILE_TIME_CHOICE_NAME})
endif()
set(PICO_DEFAULT_BOOT_STAGE2 "${PICO_DEFAULT_BOOT_STAGE2}" CACHE STRING "boot_stage2 short name" FORCE)
set(PICO_DEFAULT_BOOT_STAGE2_FILE "${CMAKE_CURRENT_LIST_DIR}/${PICO_DEFAULT_BOOT_STAGE2}.S")
endif()

if (NOT EXISTS ${PICO_DEFAULT_BOOT_STAGE2_FILE})
message(FATAL_ERROR "Specified boot_stage2 source '${PICO_BOOT_STAGE2_FILE}' does not exist.")
message(FATAL_ERROR "Specified boot_stage2 source '${PICO_DEFAULT_BOOT_STAGE2_FILE}' does not exist.")
endif()

# needed by function below
set(PICO_BOOT_STAGE2_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "")

add_library(boot_stage2_headers INTERFACE)
target_include_directories(boot_stage2_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)

# by convention the first source file name without extension is used for the binary info name
function(pico_define_boot_stage2 NAME SOURCES)
add_executable(${NAME}
Expand All @@ -29,7 +46,7 @@ function(pico_define_boot_stage2 NAME SOURCES)
# boot2_helpers include dir
target_include_directories(${NAME} PRIVATE ${PICO_BOOT_STAGE2_DIR}/asminclude)

target_link_libraries(${NAME} hardware_regs)
target_link_libraries(${NAME} hardware_regs boot_stage2_headers)
target_link_options(${NAME} PRIVATE "LINKER:--script=${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld")
set_target_properties(${NAME} PROPERTIES LINK_DEPENDS ${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld)

Expand All @@ -49,17 +66,22 @@ function(pico_define_boot_stage2 NAME SOURCES)
COMMAND ${Python3_EXECUTABLE} ${PICO_BOOT_STAGE2_DIR}/pad_checksum -s 0xffffffff ${ORIGINAL_BIN} ${PADDED_CHECKSUMMED_ASM}
)


add_library(${NAME}_library INTERFACE)
add_dependencies(${NAME}_library ${NAME}_padded_checksummed_asm)
# not strictly (or indeed actually) a link library, but this avoids dependency cycle
target_link_libraries(${NAME}_library INTERFACE ${PADDED_CHECKSUMMED_ASM})
target_link_libraries(${NAME}_library INTERFACE boot_stage2_headers)

list(GET SOURCES 0 FIRST_SOURCE)
get_filename_component(BOOT2_BI_NAME ${FIRST_SOURCE} NAME_WE)

target_compile_definitions(${NAME}_library INTERFACE
-DPICO_BOOT2_NAME="${BOOT2_BI_NAME}")
get_filename_component(BOOT_STAGE2_BI_NAME ${FIRST_SOURCE} NAME_WE)

# we only set the PICO_BUILD_STAGE2_NAME if it isn't 'compile_time_choice'
if (NOT BOOT_STAGE2_BI_NAME STREQUAL PICO_BOOT_STAGE2_COMPILE_TIME_CHOICE_NAME)
target_compile_definitions(${NAME} INTERFACE
-DPICO_BUILD_BOOT_STAGE2_NAME="${BOOT_STAGE2_BI_NAME}")
target_compile_definitions(${NAME}_library INTERFACE
-DPICO_BUILD_BOOT_STAGE2_NAME="${BOOT_STAGE2_BI_NAME}")
endif()
endfunction()

macro(pico_set_boot_stage2 TARGET NAME)
Expand Down
29 changes: 29 additions & 0 deletions src/rp2_common/boot_stage2/compile_time_choice.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// ----------------------------------------------------------------------------
// Second stage boot code
// Copyright (c) 2019-2021 Raspberry Pi (Trading) Ltd.
// SPDX-License-Identifier: BSD-3-Clause
// ----------------------------------------------------------------------------
//
// This implementation uses the PICO_BOOT_STAGE2_CHOOSE_ preprocessor defines to pick
// amongst a menu of known boot stage 2 implementations, allowing the board
// configuration header to be able to specify the boot stage 2

#include "boot_stage2/config.h"

#ifdef PICO_BUILD_BOOT_STAGE2_NAME
// boot stage2 is configured by cmake, so use the name specified there
#error PICO_BUILD_BOOT_STAGE2_NAME should not be defined for compile_time_choice builds
#else
// boot stage2 is selected by board configu header, so we have to do some work
#if PICO_BOOT_STAGE2_CHOOSE_IS25LP080
#include "boot2_is25lp080.S"
#elif PICO_BOOT_STAGE2_CHOOSE_W25Q080
#include "boot2_w28q080.S"
#elif PICO_BOOT_STAGE2_CHOOSE_W25X10CL
#include "boot2_w25x10cl.S"
#elif PICO_BOOT_STAGE2_CHOOSE_GENERIC_03H
#include "boot2_generic_03h.S"
#else
#error unknown boot stage2 choice
#endif
#endif
Loading

0 comments on commit 02b98e5

Please sign in to comment.