Commit Graph

163 Commits

Author SHA1 Message Date
paul eeepc 41c3948262 Completed parsing of dictionary #define statements to create dictionary tables.
Now lua scripts can make usb dictionary calls based off of C shared_dict*.h files.
Don't have to have separate lua tables for host, and C #defines for firmware to keep things aligned!

Tested and working on all current shared_dict*.h files including some simple error checking.
Does not permit multi-line comments, but inline is fine and properly accounted for.
defines starting with underscore are skipped to not trip up header define guard statement.
defines can't be set to other defines, macros, or math, only a decimal/hex number.

Tested and able to turn on/off/ip/op LED on kazzo.
2017-07-10 03:16:45 -05:00
Paul Molloy pinkASUS 4a24f72e3f Now able to make dictionary call from lua scripts.
Currently have redefined table that needs to align with shared dictionary
files.

Next task is to parse shared dictionary files to create tables at runtime.
2017-07-09 18:51:37 -05:00
Paul Molloy pinkASUS 2fdefde840 Have basic lua scripting working.
scripts/usb_device.lua is planned to use for usb device info prior to
connecting.  Currently just used to determine log level.

scripts/inlretro.lua is the main script called by the C main function.
Prior to passing control over to lua in inlretro.lua, commandline args
must be passed in somehow.  And the USB device must be connected to, and
usb transfer object passed to dictionary's local transfer pointer.

Not sure dictionary having a local static pointer to usb transfer struct
is a great idea, but simplest solution I could think of to keep from
complicating lua by passing the pointer/object back and forth between lua
and C.  This method mostly abstracts the usb transfer object from lua
which makes sense to me anyway.

Need to come up with a way for shared_dict_*.h defines to be made
available to lua scripts.  Seems a lua table would be the best solution,
but don't want to keep manual copies for all the defines.  These C defines
are necessary as it's the only clean way to define the dictionaries for
the firmware.  Thinking the best solution will be a lua script that
parses all shared_dict*.h files and creates tables at run time.  Planning
to hardcode some tables for now, then implement a .h file parser in lua.
2017-07-09 17:29:35 -05:00
Paul Molloy f4fe81da96 adding note to readme to build lua separately 2017-07-05 18:07:07 -05:00
paul eeepc d713dcc6c8 Deleted lua makefile from attempt to move last commit.
Updating host makefile to support building lua separate from host app.
Not the best makefile setup but it works.
1) cd host/source/lua
2) make o a
3) cd host
4) make

make clean will remove lua objects, at which point must recompile them.
2017-07-05 17:57:17 -05:00
paul eeepc d7cc5b59c2 Moving lua makefile to lua source so objects can be compiled separately. 2017-07-05 17:20:45 -05:00
paul eeepc 0b2aac8b52 Fixing compilation on linux. Needed forward slashes on includes, and -lm for linking math libraries.
Getting warning about lua's use of tmpnam, and to use mkstmp instead..  Not sure I care.
2017-07-05 02:49:52 -05:00
Paul Molloy 8efdc95748 adding inlprog.c with changes referenced in last commit. 2017-07-05 01:27:17 -05:00
Paul Molloy 2cc77e5fba Basic Lua operations working. Code from "programming in Lua 4th ed" by
Roberto Ierusalimschy.

Currently using Lua 5.3.4 downloaded from: https://www.lua.org/ftp/
lua.c and luac.c are the only files excluded as those are the standalone
lua(c) source files which aren't intented for this embedded solution.
License and logo included in lua/doc dir as required/requested.

Currently just have basic Lua creating lua state, loading libraries.
Then loading test.lua file which contain variables.
Which are then retrieved and printed.

Planning to put nearly all control code in lua which addresses all my
frustrations and complaints from last commit.  The more I learn about lua
the more I like it and look forward to it's use.  Planning to implement
the entire gui with lua as well, potentially wxlua
http://wxlua.sourceforge.net/

Plan is to do some basic lua pulling of USB device from lua scripts.
Then modify/create usb functions which can be called from lua directly.
With that should be able to start building up lua scripts to perform
everything which is currently handled by lua code.
2017-07-05 01:15:13 -05:00
Paul Molloy a8124e8983 Resolved issue where final buffer wasn't getting fully flashed.
Added check to ensure buff1 is done before quitting and resetting buffers.
Currently have a hacked load_oper_info_elements_chr function to test
CHR-ROM flashing.
NROM PRG & CHR flashing and dumping tested and working on black ASUS
win10 machine.
Firmware still doesn't implement previously added feature for oper_info
rd/wr_func pointer.  flash/dump.c simply overrides by providing the
function pointer based on memory type.

A bit frustrated with how complicated everything is currently...
Feel like there's a lack of standard for function definition and calls.
Would like majority of host program flow to be determined solely by
script calls.  Firmware is getting more generic and versatile at the cost
of being SLOW!!!  Perhaps that's okay though as it's not terribly slow in
comparision to comparable AVR kazzo firmware builds.  And with current
target to migrate to STM32 device this generic setup is much cleaner and
easier to work with.  However complexity was added to the firmware code in
order to help make it faster.  Not sure the goal of faster should take
priority over speed.  Obsessing over speed will cause issues with race
conditions, and complicate code to the point where I won't reach my goal.

With the long break since I've been working on this project it's making me
more willing to scrap some previous work for a cleaner solution more
aligned with my end goal.  I had to write some of this code to get a
better idea of my what my end goal will look like anyway.  Going to make a
couple builds for UIROM, and action53 as they're urgently needed.  But
beyond that I need to start working on script features, and STM32 support!
2017-06-04 20:13:58 -05:00
Paul Molloy c25e9e7b39 Fixing CHR-ROM dumping to align with previous PRG-ROM dump commit.
Able to flash PRG-ROM on NROM cart, but CHR-ROM not working.
Probably something to do with firmware updates only focusing on PRG-ROM
temporarily..??
2017-04-09 22:39:14 -05:00
Paul Molloy b28b2193a6 Improving dump functionality. Need to make sure buffer has completed
dump operation and is ready to be read back before calling IN transfer.
Similar to how need to make sure buffer is empty prior to out transfer.
This slows things down, but prevents problems for long read routines.
2017-02-20 01:54:34 -06:00
Paul Molloy 748c474ddb Flashing operations working, cleaning up a few items.
usb_Func_write updates buffer status if bytes remaining is zero.
Not the best solution as a buffer could be over/under run, define
MAKECHECKS to have buffer mark itself if full.
This method is faster and we always have transfer sizes match buffer sizes
anyway.
2017-02-20 01:45:22 -06:00
Paul Molloy pinkASUS 52a1b306c9 Flash NROM PRG-ROM operations are pretty well up to snuff now.
Had to add check to get cur_buff status and wait to send payload until
it's empty.  Still need to add timeout check as it'll spin forever if
there is a problem and it's never empty...

device should be able to handle buffer sizes smaller than usb transfer
but this probably isn't true if the first two bytes are stuffed into setup
packet.  Currently relies on end of (upto) 8 byte transfer to fill buffer.
MAKECHECKS would verify we don't overflow buffer..  Still kind of a half
thought out idea unfortunately.
2017-02-13 23:51:51 -06:00
Paul Molloy pinkASUS fe04496cfb Flashing NROM PRG-ROM working but unstable.
Not sure how I thought flash operations were previously working as there
were many bugs I had to correct to support flash operations properly.
Operations module appears to be working so far, still need to pass
functions to operation module.
Flash operations verify PRG-ROM 32KB writes working with file comparison.
Currently dependent on extra buffer status reads to delay next buffer.
I think the write operation is taking longer than the usb load operation.
Potentially due to slow code of operation module, but also possible I
had only been testing with slow eeepc linux machine previously.  Perhaps
combination of both.

Still need to correct issue so added buff status delays aren't needed.
buffer manager should be able to key off of status==USB_FULL but that
doesn't seem to work.  When trying I don't always get the same number of
buffers to get flashed so appear to have a race condition or something
not properly intialized..?

Need sort out sending of USB STALL if buffer isn't ready to be loaded yet.

This commit is mainly for documentation/reference purposes as things are
kind of working, but buggy/unstable.

AVR Memory Usage
----------------
Device: atmega164a

Program:    6486 bytes (39.6% Full)
(.text + .data + .bootloader)

Data:        679 bytes (66.3% Full)
(.data + .bss + .noinit)
2017-02-13 11:49:57 -06:00
Paul Molloy pinkASUS 31c063cd78 adding note to windows build readme, issue with path variables being too low for copy commands in Makefile 2017-02-10 09:37:16 -06:00
Paul Molloy babd916bf8 wrote a couple bytes to dual port board, test now reads them back. 2017-02-10 09:18:12 -06:00
Paul Molloy 5b85d76e7f commiting updated copy of .exe 2017-02-10 08:53:34 -06:00
Paul Molloy 56ea22f750 fixing some typo bugs to permit compiling. Updating test.c to perform
some dual port board tests.
2017-02-10 08:51:12 -06:00
paul eeepc d1aacecd6c Committing some edits made awhile ago that look legit.
Need to get things rolling again with this project!!!
2017-01-29 17:47:29 -06:00
paul eeepc 4b0c340eb1 Creations of operation module and dictionary.
Things appear to be working with some early testing.  Assumption that oper_info elements
are aligned in SRAM linearly appears to hold true.  Researching this I found it probably
was true, but can't be certain esp if gets changed in the future to not be purely 8byte
sized elements.
Still need to provide means to decode function numbers info function pointers.
2016-12-25 13:48:30 -06:00
paul eeepc de9b5d67a4 Basic flashing operatoins working. Still need to do some tests and erasing before flashing.
Need to verify page programmed successfully as it currently just continues even if unable to
flash proper data.  Need to make write page utilize variables for bank address based on mapper
and/or memory as currently doesn't flash CHR-ROM due to $5555 $2AAA being above address space
of CHR-ROM
2016-12-18 01:26:51 -06:00
Paul Molloy 876b526e8c Some timing tests on windows machine. Double buffering was pretty
successful only 1KBps speed drop when actually dumping real cart data.
2016-12-12 22:31:46 -06:00
paul eeepc a7eaf970b2 CHR-ROM dumping working for NROM checksum appears to be off need to compare files. 2016-12-12 10:56:53 -06:00
paul eeepc e483406c01 firmware main.hex commit from last time along with versions of other kazzos
AVR Memory Usage
----------------
Device: atmega164a

Program:    5486 bytes (33.5% Full)  ***final design last commit***
(.text + .data + .bootloader)

Data:        653 bytes (63.8% Full)
(.data + .bss + .noinit)

AVR Memory Usage
----------------
Device: atmega164a

Program:    5498 bytes (33.6% Full)  ***early purple design***
(.text + .data + .bootloader)

Data:        653 bytes (63.8% Full)
(.data + .bss + .noinit)

AVR Memory Usage
----------------
Device: atmega164a

Program:    5764 bytes (35.2% Full)  ***prototype green design***
(.text + .data + .bootloader)

Data:        655 bytes (64.0% Full)
(.data + .bss + .noinit)
2016-12-12 00:54:07 -06:00
paul eeepc c2359e67a5 Dumps offically working for PRG-ROM on NROM!!!
Found bug with setting map_n_part due to >/< instead of >=/<= for setting called_buff...
Was also setting mem_type and part backwards in dump.c
The had issues with usb timing out for more than 1 buffer read back
Problem was due to lack of usbPoll while dumping during double buffering
Adding usbPoll to page read to correct issue

Appears to be issue with dumping first byte of this choplifter cart I'm testing with.
Not so certain it's my bug though..  No matter what I do the first byte reads
back 0x78 and copy I downloaded has 0x00.  Setting my first byte to 0x00 also
creates proper CRC32 according to bootgod's database.  So need to look into this more
to figure out what's going on.
2016-12-12 00:38:01 -06:00
paul eeepc 49ec51e767 Much of dumping code for PRG-ROM completed but have some bugs with setting buff elements working on debugging... 2016-12-11 20:34:43 -06:00
paul eeepc 4db2929c3b Big overdue commit of past few days effort..
Detecting mirroring code working and tested
Started working on buffer operations from host
Current code compiles but not yet at point where can start testing
Adding cpu page read to nes.c to have faster dumping operations.
moving enums to shared as gets used quite a bit communicating between device and host.
2016-12-11 01:06:41 -06:00
paul eeepc dff396a1c2 Successful detection of UNROM512 mapper30 PRG-ROM flash
Processing input args to create rom file when dumping
Adding create_rom function in file.c working but need to add check if file already exists
Listing out number of mappers which planning to support
2016-12-09 01:58:34 -06:00
paul eeepc a89caf2454 Detecting some flash carts including NROM and UNROM.
Using CHR-RAM sensing, and flash manf/prod ID based on PRG-ROM banking

fixing bug in firmware for ppu writes was ANDing in /A13 instead of ORing..

adding datasheets to hardware folder for 5v PLCC and 3v TSOP flash used on all flash boards
2016-12-08 21:52:47 -06:00
paul eeepc d97c31db62 Determining overall operation READ/WRITE. 2016-12-07 19:19:34 -06:00
paul eeepc 66635b15e7 Making progress on main program flow with detection in preparation for dumping/writing operations.
Prepended DICT_ to dictionary names to prevent using those defines for something else accidentally
"NES/SNES" etc could be used in a lot of places, don't want to use wrong enum/define in wrong place.

created enums.h to list out all enums/defines for cartridge and memory elements in one location.

separate file.c/h file for getting data in/out of a files, and opening/closing them.

adding test roms to roms folder so they can be used for various testing.
2016-12-07 18:08:31 -06:00
paul eeepc 8654a8f4bf Reading nes file inputs and extracting data from header.
Creating rom image struct/object to store rom header data.
2016-12-05 00:42:29 -06:00
paul eeepc 497e53378b Basic cartridge detection working. NES detected with CIRAM /CE and PPU /A13N jumper. Famicom detected with audio in/out connection. SNES detected by enabling control signals and reading reset vector looking for non 0xff data. Still need to add check that would pass with blank flash cart though reading flash ID's perhaps.
Removing bad logic where TRUE == 0x00 as that's 'false' in C so that was causing more confusions than solutions.
2016-12-04 03:16:40 -06:00
Paul Molloy 132360f305 Updating main command line input args, and libusb logging/debug messages.
now able to accept LIBUSB_LOG_LEVEL from commandline to turn on/off error
messges at runtime.  Also setting level > 0 will print messages during
device discovery and connection.  Still need to permit kazzo firmware
version to be provided on commandline to support K flag.

fixing dictionary call typo with semicolon and setting buffer length
to always be provided with function call instead of dictionary call
deciding what it should be based on the opcode.

Adding some speed notes and other speed related discussions to buffer
dictionary.
2016-12-02 22:59:54 -06:00
Paul Molloy 2f8823053e making some changes to dictionary call for print options. 2016-12-01 23:15:58 -06:00
paul eeepc a24d728cea flashing page working, verified by reading back again.
currently instruct buffer to dump/flash by setting its function accordingly
2016-12-01 00:45:10 -06:00
Paul Molloy 937435220a Some early dumping functionality working.
buffer opcode updates to transfer payloads
including stuffing two bytes of write transfers in setup packet.
Calling specific buffers with miscdata or opcode.

new dump and flash modules for firmware.

new buffer function update_buffers called during main to monitor and
manage buffer objects when not being loaded/unloaded from USB.
2016-11-30 22:52:43 -06:00
paul eeepc 8cdeecdd77 adding some error checks to usbFunctionWrite.
Trying to prevent transfer from exceeding buffer size.
Also verifying buffer's status is properly set to enforce upholding of the status.
Giving usbFunctionWrite a means to communicate it's error/success back to host with USB 'dictionary'.
2016-11-30 12:53:06 -06:00
paul eeepc b6164aa3a6 adding buffer element getter and setters to dict and firmware.
Need to add to host support and test operation.
2016-11-30 02:04:07 -06:00
Paul Molloy c256ca6b66 testing some bigger transfer sizes removing some printing. 2016-11-30 00:03:40 -06:00
Paul Molloy 3326c2fb34 payload buffers working with some early testing.
Had a good lesson on what static means... :/
everything working now as previously designed
speed testing on windows10 PC yeilded ~21KBps when transferring 128-512KB
payloads and 128Byte transfer size.  Going to bump to 256 and see how that
does after 128KB speed tests on linux machine.

created host test.c/.h file for general testing of new features.
that way I can start working on erase/write.h files and just use test.c as
scratch code space for tinkering and still call with -t flag on command
line.

modified dictionary calls to include pointers to data and lengths.
2016-11-29 18:27:54 -06:00
paul eeepc cb0941e86c usbFunctionWrite support loading incoming write/OUT data to buffer objects.
Still untested, need to write some host code to test things out.
2016-11-29 15:27:31 -06:00
Paul Molloy fe1b0e0ba5 AVR Memory Usage
----------------
Device: atmega164a

Program:    4092 bytes (25.0% Full)
(.text + .data + .bootloader)

Data:        445 bytes (43.5% Full)
(.data + .bss + .noinit)

upgraded windows machine to avr-gcc (GCC) 6.1.1 20160627
dropped .hex down to within 2 bytes of linux machine running 4.8.2

changed main to remove avr-gcc 6.1.1 warnings
2016-11-28 22:53:12 -06:00
Paul Molloy 80943f7f62 firmware buffer.c reorganization and some intitial testing complete.
moved all buffer operations out of usb.c with new bridge function between
the two files.  Lots of pointing going on and lessons learned..
Thankfully everything seems to be working if you actually call the
functions as I designed them..  Gotta love trouble shooting bugs that
don't exist..  Helped updating allocate output to get returned as error
back to the host.

Moved typedef structs to firmware type.h file as seemed to cause
compilation issues being contained in the files .h file when other .c
files needed those types.

Fixed casting warnings with usbMsgPtr ended up looking at usbdrv.c figured
out how close I got, just shouldn't have been putting the * in there..
2016-11-28 22:16:35 -06:00
Paul Molloy 52ef11c7e3 AVR Memory Usage
----------------
Device: atmega164a

Program:    4186 bytes (25.5% Full)
(.text + .data + .bootloader)

Data:        445 bytes (43.5% Full)
(.data + .bss + .noinit)

buffer allocation basic operations tested and working great.
Still need to update windows machine avr-gcc..
implemented with 8 buffers and 256 raw buffer
2016-11-28 20:45:46 -06:00
Paul Molloy c36313135e Initial firmware implementation of buffer objects and raw sram allocation
complete.  should be able to allocate buffers from host, but haven't got
to testing it yet.  Compiling on firmware though..
Currently have 256 bytes of raw_buffer, and 8 buffer objects/structs
each with ~16 bytes per object.  So could trim things down, but still have
decent amount of SRAM left.  Could have another 256 byte buffer at this
rate..  but might not leave enough SRAM for temporary routines.

Possible that raw buffer space could be dynamically allocated
as either buffer space or temporary routine space...

AVR Memory Usage
----------------
Device: atmega164a

Program:    4094 bytes (25.0% Full)
(.text + .data + .bootloader)

Data:        573 bytes (56.0% Full)
(.data + .bss + .noinit)
2016-11-28 02:01:14 -06:00
paul eeepc 931222cf17 new buffer.h/.c firmware files. Mostly just comments and struct defn for now 2016-11-27 21:18:54 -06:00
Paul Molloy c6a68c679f Adding EXP0_PULLUP_TEST should probably verify pullup on EXP0 provides
logic 1 if relying on it.  Seems to work fine on NES discrete and
INLXO-ROM boards where planning to utilize it.  SNES can't pull up due to
pulldown and original famicom cart can't either perhaps because of
EXP6 EXP FF output being too much of a load..?
2016-11-27 17:47:40 -06:00
Paul Molloy 8c1eb00e85 last commit apparently didn't include the recent version, just the rename.? 2016-11-27 15:40:13 -06:00