Commit Graph

218 Commits

Author SHA1 Message Date
beyondcoast d8d610b290 Merge branch 'master' of https://gitlab.com/beyondcoast/INL-retro-progdump into cleanup 2018-12-20 07:40:36 -06:00
beyondcoast 4fec4855b6 Update .gitignore to ignore VSCode metadata 2018-12-20 07:27:46 -06:00
beyondcoast d1e9e54874 Fix reported bug about nil path using -p flag to flash cart 2018-12-20 07:25:21 -06:00
beyondcoast 2972654e3b Cleanup of Genesis console script: add unsupported messages, dead code removal, table usage inlined, fix off-by-one error, make debug msgs variable controlled. 2018-12-20 07:16:46 -06:00
paul fa2e2afe4a adding -lm flag to include math library. 2018-12-18 20:46:48 -06:00
Paul Molloy 0678b8cb10 Merge branch 'master' into 'master'
Flag support cleanup

See merge request InfiniteNesLives/INL-retro-progdump!15
2018-12-18 04:55:24 +00:00
beyondcoast 97c5258f86 Add mmc5 support to inlretro2.lua 2018-12-17 19:19:17 -06:00
beyondcoast d33e9c2489 Deduplicate some logic in inlretro2.lua, make mapper/console flags case insensitive, update --help message. 2018-12-17 19:18:21 -06:00
Paul XPS 64ebb49617 Adding support for dumping MMC5 roms, wram reading/writting probably
works, but is untested.  (I don't own a MMC5 cart with PRG-RAM)

Tested with Laser Invasion for NES (128KB PRG & CHR ROMs)
2018-12-17 00:05:30 -06:00
Paul Molloy 9b9d4aaa2b Merge branch 'master' into 'master'
Add long versions for all existing options, ex: -c => --console

See merge request InfiniteNesLives/INL-retro-progdump!14
2018-12-16 19:13:22 +00:00
beyondcoast ea204fda31 Add long versions for all existing options, ex: -c => --console 2018-12-16 12:34:22 -06:00
Paul Molloy e8058e4da1 Merge branch 'master' into 'master'
Add GBA, Sega, N64 to inlretro2/CLI support + minor cleanup.

See merge request InfiniteNesLives/INL-retro-progdump!13
2018-12-10 05:44:19 +00:00
beyondcoast 6685122c09 Support N64,GBA,Genesis in inlretro2, add CLI -z option for ROM size in megabits 2018-12-09 17:53:03 -06:00
beyondcoast 5b47ff3fe6 Merge branch 'cleanup' 2018-12-09 17:10:59 -06:00
Paul XPS c1b35baf06 Big ol' commit with addition of support for GBA, Genesis, & N64
cartridge reading!

have some cleanup to do:
clean up sega dumping so don't need a page0/1
implement sega single reads

Add GBA to some of the common opcodes

dumping Don't think need addrH |= of mapper, but maybe this is key to
cleaning up first note..

gba, sega, n64 has extra NOPs, remove and test.

create pinport renames for sega pins, move mask defines to pinport.h

clean up comments for genesis page reads..
2018-12-08 16:01:59 -06:00
beyondcoast f0865b1aed Cleanup registration of lua globals, initialize INLOptions with empty strings to avoid potential segfault. 2018-12-07 09:23:47 -06:00
Paul XPS fa71e2ef2a GBA cart dumping supported!
haven't done anything with save ram/flash yet, but should be able to
dump rom for any/all GBA carts now!  Tested with 8Mbyte Metroid Fusion.
Took ~75sec at 107KBps
2018-12-06 20:12:21 -06:00
Paul Molloy 99e3494db8 Merge branch 'master' into 'master'
Comment-pocalypse. Delete lots of commented out code in inlprog.c

See merge request InfiniteNesLives/INL-retro-progdump!12
2018-12-07 02:08:06 +00:00
beyondcoast 0471dd65c2 Comment-pocalypse. Delete lots of commented out code in inlprog.c that are left over from a pre-lua era of the software. Add TODOs in lua app for safety checks that were in the removed commented out C code. 2018-12-06 18:57:22 -06:00
Paul XPS 7fbcabf3ea adding missing INL6 dfu release from last commit 2018-12-06 01:28:29 -06:00
Paul XPS e4debe5a13 Big update for firmware version v2.3.1
this is the verion getting flashed on all v2.0N NESmaker kits
v2.3.0 worked for basic functions, but was never shipped

Majority of effort revolved around testing mapper30 boards with the
smaller v2.0N INLretro with the NES connector alone for NESmaker kits.

added linear feedback shift register for test stream data generated
locally on the device.  I'm not 100% sure if this is any faster than
pushing the actual data via USB though.. :/  It's plenty fast on the
stm32 nearly instantaneous for 32KByte.  But the AVR takes a couple
sec..

Created "stuff" dictionary for things like that were I just want to add
small things and don't want to bother with a whole new dictionary.

Added file verification to the host with files.lua

Have some nes flash algos return post-written data so calling function
can decide if want to retry, fail, etc.

Changed host dictionary calls to assert instead of error because it
really shouldn't continue.  I didn't see an error when sending opcode to
wrong dict and caused head banging..

fwupdate permits bytes to be skipped, or force the update.  Found that
the fwupdater got assigned different addresses of ram depending on what
all other ram gets allocated to the main application

Some clean up of inlretro.lua

TODO:
host learn and keep track of the connected device.
Needed for ciccom right now, or knowing whether ciccom connection
is even present..
In the end maybe ciccom is better placed in firmware, but for small
transfers of only a few bytes it kinda makes sense to keep on the host.
Pinport gets quite messy with these made up pin names when really all I
want to do is toggle a specific pin on the NES connector.  So maybe some
double mappings would actually be okay, need to rethink that..

create different flash modes that either keep going, retry, or error
depending on the goal of the flash operation.  Fanout the return value
from flash algos to all of them.

have fwupdate assigned a specific area of ram so the ram pointer doesn't
change between builds.  Okay to ignore for now.

Realized can have STM32F070C6 devices execute bootloader by erasing all
the flash or perhaps even just the first word of flash according at
AN2606.  This wouldn't work for RB devices though.  This could be done
through the bootloader dict
2018-12-06 01:07:13 -06:00
Paul XPS 542bba7583 adding support for Gameboy MBC1 rom dumping 2018-12-02 16:41:54 -06:00
Paul XPS b904a6cb11 Print out device USB/fwudpater version after successful connection. The firmware application version should be printed from scripts. 2018-12-02 15:07:55 -06:00
Paul Molloy 7ede204444 Merge branch 'master' into 'master'
Change process() interface, standardize for all NES use cases. Add more CLI functionality and remove hardcoded ROM sizes.

See merge request InfiniteNesLives/INL-retro-progdump!11
2018-12-02 19:52:41 +00:00
beyondcoast 9ed0055cd8 Merge branch 'master' of https://gitlab.com/InfiniteNesLives/INL-retro-progdump 2018-12-02 13:34:44 -06:00
beyondcoast e3a09931b7 Fix ROM Size check logic, wrong variable names in battery-backed ram mappers. 2018-12-02 13:23:57 -06:00
beyondcoast 26f403d9f6 Change interface to process() for all NES mappers to make higher level scripts more flexible in using them, eliminate hardcoded prg,chr,ram sizes. Add CLI options to drive all this functionality directly. Note: Option letters are chosen somewhat arbitarily, next change will be to use argp so more descriptive flag names can be used ex: --nes_prg_rom_size_kb=16 in addition to single character shortnames. This will be important as console support expands. 2018-12-02 13:06:22 -06:00
Paul XPS 5a1c87f020 Merge branch 'master' of https://gitlab.com/InfiniteNesLives/INL-retro-progdump 2018-12-01 22:45:54 -06:00
Paul XPS cadc615621 Have Gameboy ROM only cart dump working!
Had to fix io_reset, was trying to modify GB POWER pin before turning on
GPIO blocks..

Will be putting nightly builds for "INL6" pcb v2.0 in the build_stm
folder.  This is the primary device most people have.  Not going to
bother versioning it.  But it can easily be flashed onto devices running
v2.3 firmware which includes the fwupdater now.  There is a call
commented out in inlretro.lua which performs the firmware update to the
nightly build:

fwupdate.update_firmware("../firmware/build_stm/inlretro_stm.bin")

the binary isn't versioned so there will be a warning, when flashing
over the top of it but it can be ignored.

Only really created the gameboy page dump function so far.  Next need to
implement the read/write functions so we can start interfacing with MBC
gameboy mappers.
2018-12-01 22:38:29 -06:00
Paul Molloy c9e2d643ee Merge branch 'unrom-find-banktable' into 'master'
UNROM: automatically find banktable

See merge request InfiniteNesLives/INL-retro-progdump!10
2018-12-01 18:33:52 +00:00
Paul Molloy ec596dd963 Merge branch 'master' into 'unrom-find-banktable'
# Conflicts:
#   .gitignore
2018-12-01 17:33:39 +00:00
Paul Molloy 48b7437d10 Merge branch 'master' into 'master'
Rearchitect Makefile to support dependency tracking / fast incremental builds.…

See merge request InfiniteNesLives/INL-retro-progdump!8
2018-12-01 16:59:43 +00:00
Paul XPS d1c9b67c93 removing the firmware update call people shouldn't need this right now. 2018-12-01 10:54:30 -06:00
Paul XPS 73ae2401b8 adding missing help.lua file from last commit. 2018-12-01 10:15:19 -06:00
Paul XPS 54e3e6bf3c Big release commit for firmware v2.3.0
Put bunch of notes in Readme.txt on how to update device firmware to
v2.3 using dfusedemo.  Anyone with a device currently in their hands
will want to update to this latest version using the dfusedemo
instructions there.  Or the AVR instructions if you have an old kazzo.

For devices shipping after Dec 1st 2018 I will be flashing this latest
v2.3 firmware which has it's own firmware updater so the INLretro host
software can easily and seamlessly update the firmware for you without
any external software, switch or jumper operation on the PCB.

This update also includes some power functions in the bootloader
dictionary.  Can now make direct read/write access to the entire ARM
memory space.  Maybe I'll add this to the AVR someday..?
Having this previously would have actually allowed me to bootstrap
a switchless bootloader without dfuse..  ahh well...

Also turned the watchdog timer on for the STM32 build finally.
Requires refreshing every ~1sec, currently only done in the main.

Added application versioning to address 0x08000800 in the binary.
Couldn't get the linker script to do this for me for some reason.
So for now I just manually put it in the binary file.

The fwupdate.lua script has a lot more checks now.  Uses the new
bootloader dict functions to dump device firmware and make sure
all looks good before it starts erasing firmware.

Haven't done much testing with the current AVR build.  Got a report
there was a problem with UNROM flashing, will have to check that out.

Done with the firmware for awhile now hopefully.  Need to clean up some
things with the main program & inlretro.lua script.  Start making better
use of some recent contributions by several gracious people.

Maybe I'll get going on gameboy, GBA, & sega soon..  Got a ton of
NESmaker devices to push out the door now with this latest build.  So
might be slow for a bit..
2018-12-01 02:18:01 -06:00
beyondcoast 5691721cd6 Don't track unix binary in source control 2018-12-01 00:23:28 -06:00
beyondcoast d55cf71ac5 Add liblua.a to .gitignore 2018-12-01 00:04:32 -06:00
Sylvain Gadrat 802e3b8c83 UNROM: automatically find banktable when dumping 2018-11-30 13:42:51 +01:00
Sylvain Gadrat 75aaba1ad8 Add inlretro built binary to gitignore 2018-11-30 13:42:51 +01:00
Paul XPS ff8495455c Updating fwupdate script it's officially updating the STM32 firmware all
on it's own!!!

It flashes pretty quickly too.  The STlink takes about 8sec to erase and
write.  I'm guessing it's erasing the whole 128KByte though.  My own
fwupdater takes ~3sec to flash, ~1.5sec to erase.  So there might not
even be that much room for speed up.  3sec is hard to beat signficantly
anyway and it comes at the cost of bytes.  Perhaps even complexity and
risk of OUT packet errors/loss on the device side.  So kinda like
leaving it as is.
2018-11-30 00:37:52 -06:00
Paul XPS e3efe04836 Firmware updates are complete for switchless firmware updates via USB!
Have basic testing complete of erasing application/main code, flashing
data, and reading it back for verification.

This ended up being pretty big task to get working.  Some previous
efforts helped out quite a bit though.  The first thing needed was a
path out of the main application and this was done in bootload.c by
calling PREP_FWUPDATE.  That jumps to the fwupdate area (first 2KByte)
of flash.

There the 'fwupate main' takes over.  It updates the usbFunction
Setup/Write ram function pointers to fwupdate's own setup function.
Then it must hijack the processor's execution so once the PREP_UPDATE
exception is complete the processor returns to the fwupdater instead of
the main.  This is done by snooping back through the stack and finding
the stack frame keying off of xPSR and valid PC address.  It then stomps
the PC & LR in the stack frame to steal execution from the main thread.

After that, all usb transfers are handled by the fwupdater.
Able to get buy without the write so far since setup packets provide
data but are also IN transfers to give path for sending data back to
host.  So to keep things small and simple this is all that's handled so
far.  Once I get tired of it being so slow I can implement the
usbFunctionWrite and speed things up quite a bit.  Haven't actually
timed it yet, but for only 20KByte of data it and not being very
frequent it shouldn't be a big deal.  The more I say this the more I'm
thinking I'll add that next because I'll be using it myself so much for
development..  Less time in that state is less likely for ppl to
'semi-brick' their device.

There is of course always the stmicro dfuse demo that can always unbrick
the device.  I tried really hard to jump to their bootloader but no
matter what I did I couldn't get it working.  It was never recognized by
USB.  I half way wonder now if I needed to disable the bootpin which I
never would want to do anyway..

Created separate build_stm folders for INL6 & INL_NES which is what all
the NESmaker kits use.  Also update the make files to be more accurate
about what chip their using since fwupdate tries to prevent a hardfault
from flash access beyond what's available.

This update doesn't include a means of updating the first 2KByte of
firmware updater space itself.  But the application code should be able
to take care of that for us in a future update.  It's only 2KByte so
just temporarily storing the fresh build in SRAM will probably work.
Although will have to be careful about any calls from application code
to fwupdater.  Plus there's always dfuse..

Other problem I ran into was erasing the application code.  It worked
fine early on for all 30KByte.  But as my fwupdater function grew it
crashed when page 18 was erased.  Realized my bigger switch/case
statement was calling a gcc library function that resided in the
application code.  It was only 50Bytes, so moved it to fwupdate section.
Brought 2 of similar library functions over as well, but one of them
disappeared with update to latest version of arm-none-eabi-gcc.

Not a commit really, but this is the release where I updated gcc.  Was
previously:
gcc version 6.2.1 20161205 (release)
[ARM/embedded-6-branch revision 243739]
is now:
gcc version 7.3.1 20180622 (release) [ARM/embedded-7-branch revision
261907] (GNU Tools for Arm Embedded Processors 7-2018-q2-update)

Updating gcc provided a smaller build size of ~250 Bytes from the tail
end.  But it also freed up ~50Bytes in fwupdate space as well.
2018-11-29 22:31:26 -06:00
beyondcoast 298c9112c5 Implement -h help message for all currently implemented CLI options, fix warning about const string. 2018-11-29 20:43:41 -06:00
beyondcoast 0213df5580 Rearchitect Makefile to support dependency tracking / fast incremental builds. Lua now built and linked as static library via its own Makefile. .gitignore modified to ignore *.d Makefile fragments with dependency info. 2018-11-29 20:36:06 -06:00
Paul XPS a8a4e7e1e2 Have the usb code physically separate from the main/application code
with large number of updates to the linker script (nokeep.ld)

The first 2KByte is dedicated for vector table, usb driver, usb desc
tables, hardfault, dummy handler, and firmware update routines.  There
is currently ~700Bytes of free space in that first 2KB.  Should be
plenty of space for firmware update routines and other advanced future
features.

The 070RB has 2KByte pages, and 070C6 has 1KB pages, which is the
smallest erase granularity size.  So we can't really have anything
smaller than 2KByte on the RB.  This leaves 30Kbyte for the
main/application code on the C6 which should be more than enough.

That 30KByte starts with the reset handler fixed to 0x0800_0800 because
we don't want to have to update the vector table.

After the reset handler is the usbFunctionWrite, then Setup routines
which the usb driver calls for incoming/outgoing data.  These need to be
in first 64KByte of flash as a 16bit pointer is kept in usb_buff RAM.
Write was put first as it's less likely to change, with Setup following
which is quite large due to all the inlining that's happening inside it
thanks to the compiler.

Perhaps these function locations could be kept at a fixed location.  Or
we could make a 'vector table' of our own just before the reset handler.
This may speed things up a bit, but for now it works.  Also like the
ability to change these pointers which may be useful for the next update
as the firmware update code will effectively need it's own Setup/Write
functions.  So the current pointers can just be updated to call them
instead, and restore originals/new ones through reset.?

This leaves 96KByte of unused flash on the 070RB, don't have any plans
for this yet.  Perhaps future updates for all the connectors and
features will require it.

Also added definition for fast ram functions to .data section.  Got that
working but not sure when it may be needed..
2018-11-28 16:01:58 -06:00
Paul XPS e3d0ec434e Have the USB code effectively separated from the main application code!
Need to physically separate them now.  Then can focus on erasing &
flashing ourselves.

Added some speed checks to bnrom.lua script that I was testing usb code
with.  Was able to verify read/write speeds were no affected by changes
in this commit.  Did some testing against older firmware v2.2 though
there does seem to have been a slight slow down on write speeds.
Although, perhaps that's because of the nrom flash verifications that
are also included in this build (but not commited)..?
2018-11-27 23:26:26 -06:00
Paul XPS d0c8ab82fe Moved usbMsgPtr to usb_buff ram successfully.
Deleted shared_usb.h because it was a copy of shared_dict_usb.h

This build_stm .hex does include some NROM flash updates to allow
checking if the last byte programmed successfully because was having
weird problems with that.  But not ready to commit all those changes and
they're highly unrelated to this commit.

Now that usb code doesn't use any .data nor .bss need to fully separate
the USB firmware code from the application.  Main way to do this will be
to have usb code be effectively entirely interrupt driven.

Thinking the best way to initialize usb will to have the application
code jump to the USB ISR and maybe use some messaging system with the 2
unused usb_buff indexes (4Bytes).

The USB code will include the vector table, so it will point to the
reset handler, but that will point to the application code's reset
handler, just need to make sure that's at a fixed location.

The USB code is just over 1KByte last I checked, so dedicating 2KByte
should be good.  Erase granularity is 1 page (1KB on C6, 2KB on RB).  So
that will work well.  Write protection granularity is 4KByte, but really
we shouldn't need to use write protection as there will always be the
built in bootloader to save a bricked device.
2018-11-27 02:00:47 -06:00
Paul XPS a8d9fe55bb Moving usb code static variables from system ram to USB buffer ram.
In effort to remove USB firmware driver's dependance on .data/.bss
Started by fixing bug that wasn't allowing USB_BTABLE to be relocatable
Was neglecting byte addressing vs usb_buff[] array indexing of 16bit
half words.

Still have 4 bytes of .bss for usbMsgPtr, need to modify the
communication protocol between application code and usb code to
move/remove this pointer out of .bss there are 4 bytes of usb_buff
ram available for it to be moved into but need to ensure only 16bit
access is made.

Once that's done can separate usb code from application code and have
usb code only interrupt driven, with application code polling.
Then the usb code can sniff out firmware update packets and update
application code behind it's back.

Removed logging of transfer count since it wasn't being used

num_bytes_expecting isn't used but breaks device descriptors if cut for
some reason... so I just moved it and kept it...

Another weird issue is after reflashing the mcu via stlink the first
inlretro.exe excecution fails due to some usb error.  Not sure if it's
related to the usb code changes I just made, or possibly some other
recent updates to inlretro executable..?  I think this issue has existed
forever, but was hard to pin down and always went away after a reset.
2018-11-26 01:59:04 -06:00
Paul XPS 8d6707ef9f fixing EXP definitions for STM_NES so it'll actually build for previous
commit..
2018-11-25 22:30:04 -06:00
Paul XPS 374e0ba9b2 Merge branch 'master' of https://gitlab.com/InfiniteNesLives/INL-retro-progdump 2018-11-25 22:20:36 -06:00
Paul XPS 2013efe253 Most things working on STM_NES now with more complete pinport_al.h
definitions.  Still work left on the expansion port though..
Created *_CONN definitions so code doesn't get included for connectors
that aren't present.
Added a NES CPU write that doesn't toggle M2 but not sure if this will
really be needed for MMC2 or not..
2018-11-25 22:17:36 -06:00