Add PICO_NO_FPGA_CHECK define to remove FPGA check and save some bytes

This commit is contained in:
Luke Wren 2021-02-03 12:40:20 +00:00 committed by graham sanderson
parent 4bad452517
commit c44d5026db
2 changed files with 20 additions and 0 deletions

View File

@ -63,7 +63,17 @@ void __attribute__((noreturn)) panic_unsupported();
void __attribute__((noreturn)) panic(const char *fmt, ...);
// PICO_CONFIG: PICO_NO_FPGA_CHECK, Remove the FPGA platform check for small code size reduction, type=bool, default=0, advanced=true, group=pico_runtime
#ifndef PICO_NO_FPGA_CHECK
#define PICO_NO_FPGA_CHECK 0
#endif
#if PICO_NO_FPGA_CHECK
static inline bool running_on_fpga() {return false;}
#else
bool running_on_fpga();
#endif
uint8_t rp2040_chip_version();
static inline uint8_t rp2040_rom_version() {

View File

@ -9,9 +9,19 @@
#include "hardware/regs/tbman.h"
#include "hardware/regs/sysinfo.h"
// Note we leave the FPGA check in by default so that we can run bug repro
// binaries coming in from the wild on the FPGA platform. It takes up around
// 48 bytes if you include all the calls, so you can pass PICO_NO_FPGA_CHECK=1
// to remove it. The FPGA check is used to skip initialisation of hardware
// (mainly clock generators and oscillators) that aren't present on FPGA.
#if !PICO_NO_FPGA_CHECK
// Inline stub provided in header if this code is unused (so folding can be
// done in each TU instead of relying on LTO)
bool running_on_fpga() {
return !!((*(io_ro_32 *)TBMAN_BASE) & TBMAN_PLATFORM_FPGA_BITS);
}
#endif
#define MANUFACTURER_RPI 0x927
#define PART_RP2 0x2