Skip to content

Commit

Permalink
stm32: move qspi flash size/address values to a header
Browse files Browse the repository at this point in the history
... and use it to remove some magic 0x90000000s
  • Loading branch information
Daft-Freak committed Aug 8, 2022
1 parent 3482e6b commit 8db5590
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
9 changes: 9 additions & 0 deletions 32blit-stm32/Inc/quadspi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
#include <cstdint>

constexpr uint32_t qspi_flash_sector_size = 64 * 1024;
constexpr uint32_t qspi_flash_size = 32768 * 1024;
constexpr uint32_t qspi_flash_address = 0x90000000;

// resevered space for temp/cached files
constexpr uint32_t qspi_tmp_reserved = 4 * 1024 * 1024;
7 changes: 4 additions & 3 deletions 32blit-stm32/Src/32blit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "executable.hpp"
#include "multiplayer.hpp"
#include "power.hpp"
#include "quadspi.hpp"

#include "tim.h"
#include "rng.h"
Expand Down Expand Up @@ -652,7 +653,7 @@ bool blit_switch_execution(uint32_t address, bool force_game)
// switch to user app in external flash
qspi_enable_memorymapped_mode();

auto game_header = ((__IO BlitGameHeader *) (0x90000000 + address));
auto game_header = ((__IO BlitGameHeader *) (qspi_flash_address + address));

if(game_header->magic == blit_game_magic) {

Expand Down Expand Up @@ -732,12 +733,12 @@ RawMetadata *blit_get_running_game_metadata() {
if(!blit_user_code_running())
return nullptr;

auto game_ptr = reinterpret_cast<uint8_t *>(0x90000000 + persist.last_game_offset);
auto game_ptr = reinterpret_cast<uint8_t *>(qspi_flash_address + persist.last_game_offset);

auto header = reinterpret_cast<BlitGameHeader *>(game_ptr);

if(header->magic == blit_game_magic) {
auto end_ptr = game_ptr + (header->end - 0x90000000);
auto end_ptr = game_ptr + (header->end - qspi_flash_address);
if(memcmp(end_ptr, "BLITMETA", 8) == 0)
return reinterpret_cast<RawMetadata *>(end_ptr + 10);
}
Expand Down
8 changes: 1 addition & 7 deletions firmware/firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@
#include "executable.hpp"
#include "dialog.hpp"
#include "power.hpp"
#include "quadspi.hpp"

#include "engine/api_private.hpp"

using namespace blit;

constexpr uint32_t qspi_flash_sector_size = 64 * 1024;
constexpr uint32_t qspi_flash_size = 32768 * 1024;
constexpr uint32_t qspi_flash_address = 0x90000000;

// resevered space for temp/cached files
constexpr uint32_t qspi_tmp_reserved = 4 * 1024 * 1024;

extern CDCCommandStream g_commandStream;

FlashLoader flashLoader;
Expand Down

0 comments on commit 8db5590

Please sign in to comment.