-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use newest Device::BusPirate for macOS support
- Loading branch information
Showing
4 changed files
with
109 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,14 +40,21 @@ version 0.001 | |
|
||
=head1 DESCRIPTION | ||
|
||
The Nintendo Gameboy Advance can either boot from cartridge or over link cable. The latter is caled multiboot mode and is basically SPI and a homebrew encoding scheme. | ||
This utility allows uploading multiboot GBA images with the L<BusPirate|Device::BusPirate>. Don't forget to pass C<-specs=gba_mb.specs> to GCC if you want to link a multiboot image. The package's C<share/> subdirectory contains an L<example Makefile|https://github.com/athreef/Device-GBA/blob/master/share/testimg/Makefile> for cross-compilation. | ||
The Nintendo Gameboy Advance can either boot from cartridge or over link cable. The latter is caled multiboot mode and is basically SPI and a homebrew encoding scheme. Unfortunately, the Bus Pirate doesn't have a 100k SPI mode, so we are using 125k instead. If you encounter problems with booting, use the next lower speed (30k) as bitrate. | ||
This utility allows uploading multiboot GBA images with the L<BusPirate|Device::BusPirate>. Don't forget to pass C<-specs=gba_mb.specs> to devkitARM GCC if you want to link a multiboot image. The package's C<share/> subdirectory contains an L<example Makefile|https://github.com/athreef/Device-GBA/blob/master/share/testimg/Makefile> for cross-compilation. The wiring is as follows: | ||
|
||
GBA Bus Pirate | ||
SO --> MISO | ||
SI <-- MOSI | ||
CLK <-- CLK | ||
|
||
Note: This is still work in progress! | ||
|
||
=head1 OPTIONS | ||
|
||
=head2 pirate | ||
|
||
Buspirate COM port | ||
Buspirate COM port/device file | ||
|
||
$ gba -p <COM_port> | ||
|
||
|
@@ -85,7 +92,7 @@ Ahmad Fatoum C<< <[email protected]> >>, L<http://a3f.at> | |
|
||
Copyright (C) 2018 Ahmad Fatoum | ||
|
||
This library is free software; you can redistribute it and/or modify | ||
it under the same terms as Perl itself. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License v2.0 or later. | ||
|
||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ use open qw( :encoding(UTF-8) :std ); | |
use Module::Load qw(load); | ||
use Getopt::Long::Descriptive; | ||
use Device::GBA; | ||
use Scalar::Util 'looks_like_number'; | ||
|
||
use utf8; | ||
|
||
|
@@ -56,14 +57,21 @@ gba - Command-line code uploader for the Gameboy Advance | |
=head1 DESCRIPTION | ||
The Nintendo Gameboy Advance can either boot from cartridge or over link cable. The latter is caled multiboot mode and is basically SPI and a homebrew encoding scheme. | ||
This utility allows uploading multiboot GBA images with the L<BusPirate|Device::BusPirate>. Don't forget to pass C<-specs=gba_mb.specs> to GCC if you want to link a multiboot image. The package's C<share/> subdirectory contains an L<example Makefile|https://github.com/athreef/Device-GBA/blob/master/share/testimg/Makefile> for cross-compilation. | ||
The Nintendo Gameboy Advance can either boot from cartridge or over link cable. The latter is caled multiboot mode and is basically SPI and a homebrew encoding scheme. Unfortunately, the Bus Pirate doesn't have a 100k SPI mode, so we are using 125k instead. If you encounter problems with booting, use the next lower speed (30k) as bitrate. | ||
This utility allows uploading multiboot GBA images with the L<BusPirate|Device::BusPirate>. Don't forget to pass C<-specs=gba_mb.specs> to devkitARM GCC if you want to link a multiboot image. The package's C<share/> subdirectory contains an L<example Makefile|https://github.com/athreef/Device-GBA/blob/master/share/testimg/Makefile> for cross-compilation. The wiring is as follows: | ||
GBA Bus Pirate | ||
SO --> MISO | ||
SI <-- MOSI | ||
CLK <-- CLK | ||
Note: This is still work in progress! | ||
=head1 OPTIONS | ||
=head2 pirate | ||
Buspirate COM port | ||
Buspirate COM port/device file | ||
$ gba -p <COM_port> | ||
|
@@ -95,15 +103,28 @@ sub opt_spec { | |
: '/dev/ttyUSB0' }], | ||
|
||
[ | ||
verbosity => [ | ||
[ 'verbose' => "Verbose output" ], | ||
verbosity => hidden => { one_of => [ | ||
[ 'verbose' => "Verbose output" ], | ||
[ 'no-verbose' => "Don't output verbosely" ], | ||
], | ||
] }, | ||
], | ||
[ | ||
mb => hidden => { one_of => [ | ||
[ 'multiboot' => "Upload firmware image over multiboot protocol" ], | ||
[ 'no-multiboot|raw' => "Upload directly without multiboot handshakes" ], | ||
] }, | ||
], | ||
[ | ||
bus => hidden => { one_of => [ | ||
#[ 'uart' => "Communicate over UART" ], | ||
[ 'spi' => "Communicate over 32-bit SPI" ], | ||
] }, | ||
], | ||
[ 'cat|c' => "Cat", { default => '125k' } ], | ||
[ 'bitrate|b=s' => "BusPirate SPI speed", { default => '125k' } ], | ||
#[ 'spi|s=s' => "Linux SPI device file" ], | ||
[ 'version|v' => "show version number" ], | ||
[ 'help|h' => "display a usage message" ], | ||
[ 'version|v' => "show version number" ], | ||
[ 'help|h' => "display a usage message" ], | ||
); | ||
} | ||
|
||
|
@@ -127,13 +148,36 @@ sub validate_args { | |
exit; | ||
} | ||
|
||
if (@$args > 1) { | ||
if ($opt->{multiboot} and $opt->{uart}) { | ||
$self->usage_error( | ||
"You can specify at most one GBA program to upload\n" | ||
"Multiboot is only possible over SPI\n" | ||
); | ||
} elsif ( @$args == 0) { | ||
print STDERR "No image specified. Uploading test image...\n"; | ||
push @$args, dist_file 'Device-GBA', 'testimg/test.gba'; | ||
} | ||
|
||
$opt->{bus} = $opt->{bus} // 'spi'; | ||
if ($opt->{bus} eq 'uart' && not defined $opt->{mb}) { | ||
$self->{multiboot} = 0; | ||
} else { | ||
$self->{multiboot} = ($opt->{mb} // 'multiboot') eq 'multiboot'; | ||
} | ||
my $default_verbosity = $self->{multiboot} ? 'verbose' : 'no-verbose'; | ||
$self->{verbose} = ($opt->{verbosity} // $default_verbosity) eq 'verbose'; | ||
|
||
if ($self->{verbose} && not $self->{multiboot}) { | ||
$self->usage_error( | ||
"Verbose output is not possible when running in raw mode\n" | ||
); | ||
} | ||
|
||
if ($self->{multiboot}) { | ||
if (@$args > 1) { | ||
$self->usage_error( | ||
"You can specify at most one GBA program to upload\n" | ||
); | ||
} elsif ( @$args == 0) { | ||
print STDERR "No image specified. Uploading test image...\n"; | ||
push @$args, dist_file 'Device-GBA', 'testimg/test.gba'; | ||
} | ||
} | ||
|
||
return; | ||
|
@@ -142,9 +186,17 @@ sub validate_args { | |
sub execute { | ||
my ($self, $opt, $args) = @_; | ||
|
||
$opt->{verbosity} = $opt->{verbosity} // 'verbose'; | ||
my $gba = Device::GBA->new(buspirate => $opt->{pirate}, verbose => $opt->{verbosity} eq 'verbose', bitrate => $opt->{bitrate}); | ||
$gba->upload($args->[0]); | ||
my $gba = Device::GBA->new(buspirate => $opt->{pirate}, verbose => $self->{verbose}, bitrate => $opt->{bitrate}); | ||
if ($self->{multiboot}) { | ||
$gba->upload($args->[0]); | ||
} else { | ||
@ARGV = @$args; | ||
my $num = 0xFFFF_FFFF; | ||
while (<>) { | ||
my $num = looks_like_number($_) ? $_ : $num; | ||
printf "%08x\n", $gba->spi_writeread($num); | ||
} | ||
} | ||
|
||
return; | ||
} | ||
|
@@ -176,7 +228,7 @@ Ahmad Fatoum C<< <[email protected]> >>, L<http://a3f.at> | |
Copyright (C) 2018 Ahmad Fatoum | ||
This library is free software; you can redistribute it and/or modify | ||
it under the same terms as Perl itself. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License v2.0 or later. | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.