summaryrefslogtreecommitdiffstats
path: root/utils/hwstub/tools/lua/fiiox3ii.lua
blob: d393f46ab220d05da715ea0392bb4317b3705834 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--
-- Fiio X3II
--
FIIOX3II = {}

-- call with nil to get automatic name
function FIIOX3II.dump_ipl(file)
    if file == nil then
        file = "fiio_x3ii_ipl.bin"
    end
    print("Dumping IPL to " .. file .." ...")
    JZ.nand.rom.init()
    JZ.nand.rom.read_flags()
    local ipl = JZ.nand.rom.read_bootloader()
    JZ.nand.rom.write_to_file(file, ipl)
end

-- call with nil to get automatic name
function FIIOX3II.dump_spl(file)
    if file == nil then
        file = "fiio_x3ii_spl.bin"
    end
    print("Dumping SPL to " .. file .." ...")
    -- hardcoded parameters are specific to the Shangling M2
    local nand_params = {
        bus_width = 16,
        row_cycle = 2,
        col_cycle = 2,
        page_size = 2048,
        page_per_block = 64,
        oob_size = 128,
        badblock_pos = 0,
        badblock_page = 0,
        ecc_pos = 4,
        ecc_size = 13,
        ecc_level = 8,
        addr_setup_time = 4,
        addr_hold_time = 4,
        write_strobe_time = 4,
        read_strobe_time = 4,
        recovery_time = 13,
    }
    local spl = JZ.nand.rom.read_spl(nand_params, 0x400, 0x200)
    JZ.nand.rom.write_to_file(file, spl)
end

function FIIOX3II.dump()
    FIIOX3II.dump_ipl(nil)
    FIIOX3II.dump_spl(nil)
end