Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto trigger bootlaoder and flash with ft232rl #11

Open
ntn888 opened this issue Feb 20, 2022 · 15 comments
Open

auto trigger bootlaoder and flash with ft232rl #11

ntn888 opened this issue Feb 20, 2022 · 15 comments

Comments

@ntn888
Copy link

ntn888 commented Feb 20, 2022

i'm not sure on this, but i think the bootloader checks the uart for comm. if so:

the bootloader trigger could be automated by using a ft232rl module (very compact) in bitbang mode. just like how openOCD uses in one of it's mode.

ft232rl API:
https://ftdichip.com/Documents/AppNotes/AN_232R-01_Bit_Bang_Mode_Available_For_FT232R_and_Ft245R
http://www.ftdichip.com/Support/Documents/ProgramGuides/D2XX_Programmer's_Guide(FT_000071).pdf

i think the challenge will be to fiddle the single pin(tx) by inspecting the image...

i've seen a method where RPi is used: https://lupyuen.github.io/articles/auto
but this is more compact...

any thoughts?

@spacemeowx2
Copy link
Owner

Do you mean this:

pub fn reset(&mut self) -> Result<(), Error> {
self.serial.set_rts(false)?;
sleep(Duration::from_millis(50));
self.serial.set_dtr(true)?;
sleep(Duration::from_millis(50));
self.serial.set_dtr(false)?;
sleep(Duration::from_millis(50));
Ok(())
}
pub fn reset_to_flash(&mut self) -> Result<(), Error> {
self.serial.set_rts(true)?;
sleep(Duration::from_millis(50));
self.serial.set_dtr(true)?;
sleep(Duration::from_millis(50));
self.serial.set_dtr(false)?;
sleep(Duration::from_millis(50));
self.serial.set_rts(false)?;
sleep(Duration::from_millis(50));
Ok(())
}

@ntn888
Copy link
Author

ntn888 commented Feb 20, 2022

yes,

@ntn888
Copy link
Author

ntn888 commented Feb 20, 2022

but the ftdi bridge has only 1 usb, how do yo connect to the bl602?

@ntn888
Copy link
Author

ntn888 commented Feb 20, 2022

pinout?
pinout

@ntn888
Copy link
Author

ntn888 commented Feb 20, 2022

oh the tx0, rx0 pins are on the breakout... this is easier than I thought, same code to flash... just different bridge!!
kudos for impl. the auto-reset!! 👍

~/Downloads/blflash-linux-amd64 flash blink.bin --port /dev/ttyUSB0                   

[INFO  blflash::flasher] Start connection...
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 7.924643ms
[TRACE blflash::connection] read_response err: [3c, 4b]
[TRACE blflash::connection] read_response err: [42, 42]
[TRACE blflash::connection] read_response err: [28, a8]
[TRACE blflash::connection] read_response err: [f0, f0]
[TRACE blflash::connection] read_response err: [7c, e1]
[DEBUG blflash::flasher] Retry 1
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 7.632275ms
[TRACE blflash::connection] read_response err: [71, ca]
[TRACE blflash::connection] read_response err: [2c, 5b]
[TRACE blflash::connection] read_response err: [51, c0]
[TRACE blflash::connection] read_response err: [c1, 60]
[TRACE blflash::connection] read_response err: [c3, 64]
[DEBUG blflash::flasher] Retry 2
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 7.643651ms
[TRACE blflash::connection] read_response err: [f8, c1]
[TRACE blflash::connection] read_response err: [c0, 51]
[TRACE blflash::connection] read_response err: [51, 40]
[TRACE blflash::connection] read_response err: [59, 28]
[TRACE blflash::connection] read_response err: [e0, c1]
[DEBUG blflash::flasher] Retry 3
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 7.543551ms
[TRACE blflash::connection] read_response err: [c0, c9]
[TRACE blflash::connection] read_response err: [e0, e8]
[TRACE blflash::connection] read_response err: [c1, 41]
[TRACE blflash::connection] read_response err: [c1, 64]
[TRACE blflash::connection] read_response err: [ea, c0]
[DEBUG blflash::flasher] Retry 4
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 7.72075ms
[TRACE blflash::connection] read_response err: [43, fa]
[TRACE blflash::connection] read_response err: [c0, f8]
[TRACE blflash::connection] read_response err: [f9, 60]
[TRACE blflash::connection] read_response err: [a0, e9]
[TRACE blflash::connection] read_response err: [f8, b0]
[DEBUG blflash::flasher] Retry 5
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 7.620683ms
[TRACE blflash::connection] read_response err: [40, d8]
[DEBUG blflash::flasher] Retry 6
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 6.585363ms
[DEBUG blflash::flasher] Retry 7
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 6.299506ms
[DEBUG blflash::flasher] Retry 8
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 5.966381ms
[DEBUG blflash::flasher] Retry 9
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 6.070779ms
[DEBUG blflash::flasher] Retry 10
Error: Failed to connect to the device

/dev/ttyUSB0 is ft232rl ?? is right? how do i make the connections?

@ntn888
Copy link
Author

ntn888 commented Feb 20, 2022

DTR -> EN
RTS -> D8
is right?

@ntn888
Copy link
Author

ntn888 commented Feb 20, 2022

could you please add instructions on how to do this in Readme? many thanks

@ntn888
Copy link
Author

ntn888 commented Feb 20, 2022

hi, it doesnt even program through the ftdi, even if i manually press the button? i get the same error!

@ntn888
Copy link
Author

ntn888 commented Feb 21, 2022

okay success!

i had to desolder out the onboard usb ic...

@ntn888 ntn888 closed this as completed Feb 21, 2022
@ntn888
Copy link
Author

ntn888 commented Feb 21, 2022

actually it was already in bootloadre mode (but can flash). i think the following change is necessary:

 pub fn reset_to_flash(&mut self) -> Result<(), Error> {

        self.serial
            .reconfigure(&|setup: &mut dyn SerialPortSettings| setup.set_flow_control(RTSCTS))?;
        self.serial.set_rts(true)?;
        sleep(Duration::from_millis(50));
        self.serial.set_dtr(true)?;
        sleep(Duration::from_millis(50));
        self.serial.set_dtr(false)?;
        sleep(Duration::from_millis(50));
        self.serial.set_rts(false)?;
        sleep(Duration::from_millis(50));
        self.serial
            .reconfigure(&|setup: &mut dyn SerialPortSettings| setup.set_flow_control(FlowNone))?;

        Ok(())
    }

pls have a look; I dont know Rust...

@ntn888 ntn888 reopened this Feb 21, 2022
@ntn888
Copy link
Author

ntn888 commented Feb 21, 2022

my bad, the signals are correctly working... checked it with the probe...
maybe the buttons on the board bl-dt10 need to be removed...

@ntn888
Copy link
Author

ntn888 commented Feb 21, 2022

D8 is active low, need to reverse...

@ntn888
Copy link
Author

ntn888 commented Feb 21, 2022

Screenshot from 2022-02-21 19-05-16

@ntn888
Copy link
Author

ntn888 commented Feb 21, 2022

    pub fn reset(&mut self) -> Result<(), Error> {
        self.serial.set_rts(true)?;
        sleep(Duration::from_millis(50));
        self.serial.set_dtr(true)?;
        sleep(Duration::from_millis(50));
        self.serial.set_dtr(false)?;
        sleep(Duration::from_millis(50));

        Ok(())
    }

    pub fn reset_to_flash(&mut self) -> Result<(), Error> {
        self.serial.set_rts(false)?;
        sleep(Duration::from_millis(50));
        self.serial.set_dtr(true)?;
        sleep(Duration::from_millis(50));
        self.serial.set_dtr(false)?;
        sleep(Duration::from_millis(50));
        self.serial.set_rts(false)?;
        sleep(Duration::from_millis(50));

        Ok(())
    }

~/blflash/target/debug/blflash flash blink.bin --port /dev/ttyUSB0
[INFO  blflash::flasher] Start connection...
[TRACE blflash::flasher] 5ms send count 55
[TRACE blflash::flasher] handshake sent elapsed 4.895562ms
[INFO  blflash::flasher] Connection Succeed
[INFO  blflash] Bootrom version: 1
[TRACE blflash] Boot info: BootInfo { len: 14, bootrom_version: 1, otp_info: [0, 0, 0, 0, 3, 0, 0, 0, 57, 1f, c3, 5, b9, 18, 19, 0] }
[INFO  blflash::flasher] Sending eflash_loader...
[INFO  blflash::flasher] Finished 3.00971273s 9.50KiB/s
[TRACE blflash::flasher] 5ms send count 500
[TRACE blflash::flasher] handshake sent elapsed 12.170592ms
[INFO  blflash::flasher] Entered eflash_loader
[INFO  blflash::flasher] Skip segment addr: 0 size: 47504 sha256 matches
[INFO  blflash::flasher] Skip segment addr: e000 size: 272 sha256 matches
[INFO  blflash::flasher] Skip segment addr: f000 size: 272 sha256 matches
[INFO  blflash::flasher] Skip segment addr: 10000 size: 86496 sha256 matches
[INFO  blflash::flasher] Skip segment addr: 1f8000 size: 5671 sha256 matches
[INFO  blflash] Success

@lupyuen
Copy link

lupyuen commented Jul 16, 2022

There's a discussion here about BL command-line flashing, wonder if it might be helpful...

https://bbs.bouffalolab.com/d/132-cli-firmware-update-via-openocd-on-bl702

Or perhaps we could ask around on the Pine64 #nutcracker channel on Matrix, Telegram, Discord or IRC...

https://wiki.pine64.org/wiki/Main_Page#Chat_Platforms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants