Commit Graph

38 Commits

Author SHA1 Message Date
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
beyondcoast ea204fda31 Add long versions for all existing options, ex: -c => --console 2018-12-16 12:34:22 -06: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 f0865b1aed Cleanup registration of lua globals, initialize INLOptions with empty strings to avoid potential segfault. 2018-12-07 09:23:47 -06: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
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
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 b75773c8cb Eliminate some warnings in usb_operations.c, refactor logic related to option parsing, usb init, lua init in inprog.c, initial prototype of inlretro2.lua that handles options from cmd line, streamlined execution 2018-11-23 21:06:17 -06:00
Paul Molloy 8b5650b75f Well over due commit with lots of updates..
Have separate lua modules now in scripts/app folder
Dictionary calls are now their own lua module
firmware now capable of calling multiple different dictionaries
have firmware & lua io and nes dictionaries, able to detect
NES and famicom carts.  Created expansion port abstraction so most kazzo
versions behave identically.
Created separate make file for stm adapter and inl6
added PURPLE_KAZZO and GREEN_KAZZO defines back in.  They work well enough
for sensing NES vs famicom carts so far.  GREEN_KAZZO requires
PURPLE_KAZZO to also be defined.  GREEN_KAZZO is also only compatible with
AVR_CORE due to software_AHL/AXL functions specifically written for AVR.
I think things will work if a STM_ADAPTER is placed on a PURPLE_KAZZO and
both those defines are made as only real difference is software tying of
AXL and X_OE.  But haven't tested this aside from ensuring it compiles.
Have correction to pinport_al.h that will commit immediately after this.
2017-08-05 16:04:59 -05:00
Paul Molloy ec725f7e33 Getting closer to how I'd like to handle dictionary calls with lua.
Effectively deleted old dictionary call function/files.
Created lua_usb_vend_xfr function so lua can directly send and receive
vendor setup transfers.

Dictionary calls are more like function calls now, and all args aren't
required so the LED can be turned on for example in lua like so:
dict_pinport("LED_ON")
general format is:
dict_name( opcode, operand, misc, datastring )
Also added ability to store opcode's return length in shared dict library
files with RL=number in the comments following the opcode.
Negative numbers designate OUT transfers, positive for IN.
Default value can be determined by each dictionary's calling function.
Decided pinport is 1 for SUCCESS/ERROR CODE.
Also have default return data means with second byte giving length of
return data in bytes that follows.
dictionary call function reports any errors reported by the device and
returns any return data from the device excluding error code / data len

Now time to start implementing some of these dictionaries on the device.
2017-08-01 17:17:13 -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 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 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 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 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 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 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 94ea3fd474 modified: host/source/inlprog.c
new file:   host/source/erase.c
new file:   host/source/erase.h
	creating erase files called from main with e_flag

modified:   firmware/source/usb.c
	introducing switch statement with range of values of opcode type detection.

modified:   host/source/usb_operations.h
	turning off debug

modified:   shared/shared_errors.h
	renumbering some error codes
	thinking I'll have codes which can come from avr set to 128+
2016-11-26 14:17:34 -06:00
paul eeepc dae63f73b0 Tons of edits...
rearranged some of the .h files, created dictionary file to list all dictionaries of opcodes.
        moved error codes to shared file so host can interpret firmware error codes.
        created firmware usb.c/h to handle usb operations (didn't move as git seems to think..)
	cleaned up fw main function and file.
	host usb_operations, created USBrequest struct type to more easily handle all transfer info.

Currently able to send pinport commands and read back return values from retro prog.
Just need to start writting functions to send opcodes and start actually preforming some cartridge operations.
2016-11-25 19:50:43 -06:00
paul eeepc 70e700c7e8 Prepending 'shared' to files in shared folder to make more clear that these files should only be edited from the shared folder as they're copied into source folder at compile time. Any edits from source folder will get stopped, and committing shared files outside of shared folder is not desired. 2016-11-22 00:52:06 -06:00
Paul Molloy b8be4b768a new file: shared/usb_commands.h
-shared .h files used in both firmware and host app
modified:   firmware/Makefile
modified:   host/Makefile
	-added shared dependency to copy shared files to source prior to
	building
modified:   host/source/usb_operations.h
modified:   firmware/source/main.c
	-removing usb commands (now in shared)
modified:   host/include/dbg.h
	-adding SUCCESS defintion
modified:   host/source/inlprog.c
	-calling write file if write arg sent
new file:   host/source/write_operations.c
new file:   host/source/write_operations.h
	-creation of write operations files
	-opens file and reads header
	-some skeleton comments
	-lots of work left to do here
new file:   roms/nrom_v_test.nes
	-adding NROM test rom file
2016-11-20 23:57:09 -06:00
paul eeepc cfffe554be modified: source/inlprog.c
-introducing getopt to obtain commandline args
modified:   source/usb_operations.c
	-moving USB defn comments in from main
2016-11-20 15:43:11 -06:00
paul eeepc 4cbeff1ecf modified: source/inlprog.c
- removing compile errors
	- fixing request/command for off (was always sending on copy paste error)
modified:   source/usb_operations.c
	- Adding checks beyond VID/PID pair
	- Now check Manufacturer, Product, and build version
	- Give Warnings/Error if device is not supported
	- Don't blindly accept and try to write to non-supported devices.
	- Cleared up confusion on ENDPOINT direction.
2016-11-19 23:58:47 -06:00
Paul Molloy 49c9876770 modified: source/inlprog.c
modified:   source/usb_operations.c
modified:   source/usb_operations.h
	-moving usb transfer operation to usb_operations
2016-11-19 21:32:54 -06:00
Paul Molloy 782ed343f7 modified: source/inlprog.c
-moved usb device operations into usb_operations module
new file:   source/usb_operations.c
new file:   source/usb_operations.h
	-creation of usb_operations module
	-currently handles libusb open/close and retrieving INL retro-prog
	usb handle.
2016-11-19 19:10:13 -06:00
paul eeepc 37c79429ea modified: source/inlprog.c
-moving returnvalue "rv" declaration/init earlier to ensure initization.
	-adding notes to user if LIBUSB_ERROR_ACCESS as it's expected on linux.

modified:   udev-rule-help/Readme.txt
	-including expected libusb error if user doesn't have access.
2016-11-19 17:38:12 -06:00
Paul Molloy b1e60a35df host\Makefile: fixing make debug, Zed's logic seems backwards to me.
host\include\dbg.h: reversing DEBUG logic.
host\source\inlprog.c: working through making code more robust with proper
error checking via "Zed's AWESOME debug macros" ;)
2016-11-19 16:51:50 -06:00
paul eeepc ad1037b694 First commit for Makefile and main inlretro program.
Makefile copied from the Makefile I came up with during Zed Shaw's LCTHW
inlretro.c basic usb functionality using libusb 1.0
	-searches through usb devices and opens matching VID/PID
	-sends vendor xfr command for LED ON/OFF
	-closes out usb device prior to exit
	-lots of messy comments as notes while learning libusb
2016-11-19 01:20:20 -06:00