Initial Release

This commit is contained in:
graham sanderson
2021-01-20 10:49:34 -06:00
commit 46078742c7
245 changed files with 21157 additions and 0 deletions

18
flash/nuke/CMakeLists.txt Normal file
View File

@@ -0,0 +1,18 @@
add_executable(flash_nuke
nuke.c
)
target_link_libraries(flash_nuke
pico_stdlib
hardware_flash
)
# It doesn't make sense to run this program from flash. Always build a
# RAM-only binary.
pico_set_binary_type(flash_nuke no_flash)
pico_add_extra_outputs(flash_nuke)
# add url via pico_set_program_url
example_auto_set_url(flash_nuke)

47
flash/nuke/nuke.c Normal file
View File

@@ -0,0 +1,47 @@
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
// Obliterate the contents of flash. This is a silly thing to do if you are
// trying to run this program from flash, so you should really load and run
// directly from SRAM. You can enable RAM-only builds for all targets by doing:
//
// cmake -DPICO_NO_FLASH=1 ..
//
// in your build directory. We've also forced no-flash builds for this app in
// particular by adding:
//
// pico_set_binary_type(flash_nuke no_flash)
//
// To the CMakeLists.txt app for this file. Just to be sure, we can check the
// define:
#if !PICO_NO_FLASH
#error "This example must be built to run from SRAM!"
#endif
#include "pico/stdlib.h"
#include "hardware/flash.h"
#include "pico/bootrom.h"
int main() {
flash_range_erase(0, PICO_FLASH_SIZE_BYTES);
// Leave an eyecatcher pattern in the first page of flash so picotool can
// more easily check the size:
static const uint8_t eyecatcher[FLASH_PAGE_SIZE] = "NUKE";
flash_range_program(0, eyecatcher, FLASH_PAGE_SIZE);
// Flash LED for success
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
for (int i = 0; i < 3; ++i) {
gpio_put(PICO_DEFAULT_LED_PIN, 1);
sleep_ms(100);
gpio_put(PICO_DEFAULT_LED_PIN, 0);
sleep_ms(100);
}
// Pop back up as an MSD drive
reset_usb_boot(0, 0);
}