Laczen commented on code in PR #19255: URL: https://github.com/apache/nuttx/pull/19255#discussion_r3528021974
########## arch/arm/src/rp23xx/rp23xx_flash_mtd.c: ########## @@ -0,0 +1,478 @@ +/**************************************************************************** + * arch/arm/src/rp23xx/rp23xx_flash_mtd.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * This implements an MTD device spanning the entire on-chip QSPI flash of + * the RP2350. Callers layer partitions on top of it with mtd_partition() + * (e.g. a LittleFS data partition beyond the NuttX image, and/or a + * firmware/OTA slot); keeping the MTD whole-device means the region the + * NuttX image lives in stays addressable for updates. + * + * Because the RP2350 normally executes code directly from this same flash + * (execute-in-place, XIP), no code may be fetched from flash while a block + * is being erased or programmed. Therefore the erase/program routines run + * from RAM (the ".time_critical.*" section, copied into RAM with .data at + * startup) and run with interrupts disabled. + * + * The RP2350 flash-programming sequence follows the Raspberry Pi Pico SDK + * (hardware_flash/flash.c) and the RP2350 datasheet bootrom chapter: + * + * - the bootrom flash helpers are looked up via rom_func_lookup(); + * - after flash_flush_cache() the bootrom already leaves the flash in a + * basic (readable) XIP state, so XIP is re-enabled by calling the + * bootrom flash_enter_cmd_xip() helper (no copied BOOTRAM setup + * function needed); + * - the QMI window-1 (CS1) registers, which flash_exit_xip() disturbs on + * the RP2350, are saved before and restored after the operation. + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/arch.h> +#include <nuttx/irq.h> +#include <nuttx/mutex.h> +#include <nuttx/mtd/mtd.h> Review Comment: Remove, included by `rp23xx_flash_mtd.h` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
