small fixes

This commit is contained in:
Polprzewodnikowy 2022-09-24 02:22:14 +02:00
parent 0f42c6e0d7
commit 4c7783f740
13 changed files with 32 additions and 27 deletions

View File

@ -7,7 +7,7 @@ SIZE = $(TOOLCHAIN)size
PYTHON = python3
FLAGS = -march=vr4300 -mtune=vr4300 $(USER_FLAGS)
CFLAGS = -Os -Wall -ffunction-sections -fdata-sections -ffreestanding -G 0 -MMD -MP
CFLAGS = -Os -Wall -ffunction-sections -fdata-sections -ffreestanding -MMD -MP
ASFLAGS = -Wa,-I$(N64_INST)/mips64-elf/lib
LDFLAGS = -lc -nostartfiles -Wl,--gc-sections

View File

@ -5,7 +5,7 @@
#include <stdint.h>
extern const uint32_t assets_sc64_logo_640_240_dimmed;
extern const uint32_t assets_sc64_logo_640_240_dimmed __attribute__((section(".assets")));
#endif

View File

@ -3,7 +3,7 @@
#include "io.h"
extern uint32_t ipl2;
extern uint32_t ipl2 __attribute__((section(".data")));
typedef struct {

View File

@ -15,7 +15,7 @@
/ and optional writing functions as well. */
#define FF_FS_MINIMIZE 0
#define FF_FS_MINIMIZE 2
/* This option defines minimization level to remove some basic API functions.
/
/ 0: Basic functions are fully enabled.
@ -25,7 +25,7 @@
/ 3: f_lseek() function is removed in addition to 2. */
#define FF_USE_FIND 1
#define FF_USE_FIND 0
/* This option switches filtered directory read functions, f_findfirst() and
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
@ -52,7 +52,7 @@
/ (0:Disable or 1:Enable) */
#define FF_USE_FORWARD 1
#define FF_USE_FORWARD 0
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
@ -153,7 +153,7 @@
/ on character encoding. When LFN is not enabled, these options have no effect. */
#define FF_FS_RPATH 1
#define FF_FS_RPATH 0
/* This option configures support for relative path.
/
/ 0: Disable relative path and remove related functions.

View File

@ -1,7 +1,7 @@
.set noat
.set noreorder
.section .text.ipl2
.section .data.ipl2
ipl2:
.global ipl2
lui $t5, 0xBFC0

View File

@ -117,12 +117,12 @@ void sc64_get_time (rtc_time_t *t) {
bool sc64_usb_write_ready (void) {
uint32_t result[2];
sc64_execute_cmd(SC64_CMD_USB_WRITE_STATUS, NULL, result);
return result[0];
return (!(result[0] & (1 << 31)));
}
bool sc64_usb_write (uint32_t *address, uint32_t length) {
bool sc64_usb_write (uint32_t *address, uint8_t type, uint32_t length) {
while (!sc64_usb_write_ready());
uint32_t args[2] = { (uint32_t) (address), length };
uint32_t args[2] = { (uint32_t) (address), ((type << 24) | (length & 0xFFFFFF)) };
return sc64_execute_cmd(SC64_CMD_USB_WRITE, args, NULL);
}
@ -146,7 +146,7 @@ bool sc64_usb_read (uint32_t *address, uint32_t length) {
}
do {
sc64_execute_cmd(SC64_CMD_USB_READ_STATUS, NULL, result);
} while(result[0] & (1 << 24));
} while(result[0] & (1 << 31));
return false;
}

View File

@ -102,7 +102,7 @@ void sc64_get_boot_info (sc64_boot_info_t *info);
void sc64_set_time (rtc_time_t *t);
void sc64_get_time (rtc_time_t *t);
bool sc64_usb_write_ready (void);
bool sc64_usb_write (uint32_t *address, uint32_t length);
bool sc64_usb_write (uint32_t *address, uint8_t type, uint32_t length);
bool sc64_usb_read_ready (uint8_t *type, uint32_t *length);
bool sc64_usb_read (uint32_t *address, uint32_t length);
bool sc64_sd_card_init (void);

View File

@ -2,8 +2,8 @@
#include <sys/types.h>
extern char _sheap;
extern char _eheap;
extern char _sheap __attribute__((section(".data")));
extern char _eheap __attribute__((section(".data")));
caddr_t _sbrk_r (struct _reent *prt, ptrdiff_t incr) {

View File

@ -6,7 +6,7 @@ OBJDUMP = $(TOOLCHAIN)objdump
SIZE = $(TOOLCHAIN)size
FLAGS = -mcpu=cortex-m0plus -mthumb -DSTM32G030xx $(USER_FLAGS) -g -ggdb3
CFLAGS = -Og -Wall -ffunction-sections -fdata-sections -ffreestanding -MMD -MP -I./lib
CFLAGS = -Os -Wall -ffunction-sections -fdata-sections -ffreestanding -MMD -MP -I./lib
LDFLAGS = -nostartfiles -Wl,--gc-sections
SRC_DIR = src

View File

@ -402,12 +402,14 @@ void cfg_process (void) {
break;
case 'M':
if (cfg_translate_address(&args[0], args[1], false)) {
if (cfg_translate_address(&args[0], args[1] & 0xFFFFFF, false)) {
cfg_set_error(CFG_ERROR_BAD_ADDRESS);
return;
}
usb_create_packet(&packet_info, PACKET_CMD_DEBUG_OUTPUT);
packet_info.dma_length = args[1];
packet_info.data_length = 4;
packet_info.data[0] = args[1];
packet_info.dma_length = args[1] & 0xFFFFFF;
packet_info.dma_address = args[0];
packet_info.done_callback = cfg_set_usb_output_ready;
if (usb_enqueue_packet(&packet_info)) {
@ -422,7 +424,7 @@ void cfg_process (void) {
break;
case 'U':
args[0] = p.usb_output_ready ? 1 : 0;
args[0] = p.usb_output_ready ? 0 : (1 << 31);
break;
case 'i':

View File

@ -286,16 +286,15 @@ static void hw_flash_unlock (void) {
while (FLASH->SR & FLASH_SR_BSY1);
if (FLASH->CR & FLASH_CR_LOCK) {
FLASH->KEYR = 0x45670123;
__ISB();
FLASH->KEYR = 0xCDEF89AB;
}
}
void hw_flash_erase (void) {
hw_flash_unlock();
FLASH->CR |= FLASH_CR_MER1;
FLASH->CR |= FLASH_CR_STRT;
FLASH->CR |= (FLASH_CR_STRT | FLASH_CR_MER1);
while (FLASH->SR & FLASH_SR_BSY1);
FLASH->CR &= ~(FLASH_CR_MER1);
}
void hw_flash_program (uint32_t offset, hw_flash_t value) {
@ -305,9 +304,6 @@ void hw_flash_program (uint32_t offset, hw_flash_t value) {
__ISB();
*(__IO uint32_t *) (FLASH_BASE + offset + 4) = ((value >> 32) & 0xFFFFFFFF);
while (FLASH->SR & FLASH_SR_BSY1);
if (FLASH->SR & FLASH_SR_EOP) {
FLASH->SR |= FLASH_SR_EOP;
}
FLASH->CR &= ~(FLASH_CR_PG);
}

View File

@ -390,7 +390,7 @@ void usb_get_read_info (uint32_t *args) {
args[0] = p.rx_args[0] & 0xFF;
args[1] = p.rx_args[1];
}
args[0] |= (p.read_length > 0) ? (1 << 24) : 0;
args[0] |= (p.read_length > 0) ? (1 << 31) : 0;
}
void usb_init (void) {

View File

@ -536,7 +536,14 @@ class SC64:
print(data.decode('EUC-JP', errors='backslashreplace'), end='')
def __handle_usb_packet(self, data: bytes) -> None:
print(data)
header = self.__get_int(data[0:4])
datatype = ((header >> 24) & 0xFF)
length = (header & 0xFFFFFF)
packet = data[4:]
if (datatype == 0x01):
print(packet.decode('UTF-8', errors='backslashreplace'), end='')
else:
print(f'Unhandled USB packet - datatype: [{datatype}], length: [{length}]')
def debug_loop(self, isv: bool=False, disks: Optional[list[str]]=None) -> None:
dd = None