Skip to content

Commit

Permalink
Support i.MX 815 chip
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Li <Frank.Li@nxp.com>
  • Loading branch information
nxpfrankli committed May 21, 2019
1 parent 4ac93b2 commit d2fca8f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 20 deletions.
1 change: 1 addition & 0 deletions libuuu/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Config::Config()
push_back(ConfigItem("SDPS:", "MX8QXP", NULL, NXP_VID, 0x012F, 0x0002));
push_back(ConfigItem("SDPS:", "MX8QM", "MX8QXP", NXP_VID, 0x0129, 0x0002));
push_back(ConfigItem("SDPS:", "MX28", NULL, FSL_VID, 0x004f));
push_back(ConfigItem("SDPS:", "MX815", NULL, NXP_VID, 0x013E));
push_back(ConfigItem("SDP:", "MX7D", NULL, FSL_VID, 0x0076));
push_back(ConfigItem("SDP:", "MX6Q", NULL, FSL_VID, 0x0054));
push_back(ConfigItem("SDP:", "MX6D", "MX6Q", FSL_VID, 0x0061));
Expand Down
5 changes: 5 additions & 0 deletions libuuu/hidreport.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class HIDReport
m_out_buff.resize(m_size_out + m_size_payload);
m_skip_notify = true;
}
void set_out_package_size(int sz)
{
m_size_out = sz;
m_out_buff.resize(m_size_out + m_size_payload);
}
HIDReport()
{
init();
Expand Down
5 changes: 3 additions & 2 deletions libuuu/rominfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ ROM_INFO g_RomInfo[] =
{ "MX7ULP", 0x2f018000, ROM_INFO_HID | ROM_INFO_HID_MX6 | ROM_INFO_HID_SKIP_DCD },
{ "MXRT106X", 0x1000, ROM_INFO_HID | ROM_INFO_HID_MX6 | ROM_INFO_HID_SKIP_DCD },
{ "MX8QXP", 0x0, ROM_INFO_HID | ROM_INFO_HID_NO_CMD | ROM_INFO_HID_UID_STRING },
{ "MX28", 0x0, ROM_INFO_HID},
{ "MX28", 0x0, ROM_INFO_HID},
{ "MX815", 0x0, ROM_INFO_HID | ROM_INFO_HID_NO_CMD | ROM_INFO_HID_UID_STRING | ROM_INFO_HID_EP1 | ROM_INFO_HID_PACK_SIZE_1020 },
{ "SPL", 0x0, ROM_INFO_HID | ROM_INFO_HID_MX6 | ROM_INFO_SPL_JUMP },
{ "SPL1", 0x0, ROM_INFO_HID | ROM_INFO_HID_MX6 | ROM_INFO_SPL_JUMP | ROM_INFO_AUTO_SCAN_UBOOT_POS},
};
Expand Down Expand Up @@ -144,4 +145,4 @@ size_t GetContainerActualSize(shared_ptr<FileBuffer> p, size_t offset)
hdr = (struct rom_container *)(p->data() + offset + sz);

return sz;
}
}
1 change: 1 addition & 0 deletions libuuu/rominfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#define ROM_INFO_HID_NO_CMD 0x400
#define ROM_INFO_SPL_JUMP 0x800
#define ROM_INFO_HID_EP1 0x1000
#define ROM_INFO_HID_PACK_SIZE_1020 0x2000

#include <stdint.h>
#include <stddef.h>
Expand Down
26 changes: 18 additions & 8 deletions libuuu/sdps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,31 @@ struct _ST_HID_CBW

#pragma pack ()

#include "rominfo.h"

int SDPSCmd::run(CmdCtx *pro)
{
ROM_INFO * rom;
rom = search_rom_info(pro->m_config_item);
if (rom == NULL)
{
string_ex err;
err.format("%s:%d can't get rom info", __FUNCTION__, __LINE__);
set_last_err_string(err);
return -1;
}

HIDTrans dev;
if (rom->flags & ROM_INFO_HID_EP1)
dev.set_hid_out_ep(1);

if(dev.open(pro->m_dev))
return -1;

shared_ptr<FileBuffer> p = get_file_buffer(m_filename);
if (!p)
return -1;

ROM_INFO * rom;
rom = search_rom_info(pro->m_config_item);
if (rom == NULL)
{
set_last_err_string("Fail found ROM info");
return -1;
}

HIDReport report(&dev);
report.m_skip_notify = false;

Expand Down Expand Up @@ -123,6 +130,9 @@ int SDPSCmd::run(CmdCtx *pro)
return ret;
}

if (rom->flags & ROM_INFO_HID_PACK_SIZE_1020)
report.set_out_package_size(1020);

int ret = report.write(p->data() + m_offset, sz, 2);

if (ret == 0)
Expand Down
33 changes: 24 additions & 9 deletions libuuu/trans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,31 @@ int HIDTrans::write(void *buff, size_t size)
{
int ret;
uint8_t *p = (uint8_t *)buff;
ret = libusb_control_transfer(
(libusb_device_handle *)m_devhandle,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
m_set_report,
(2 << 8) | p[0],
0,
p,
size,
1000
int actual_size;
if (m_outEP)
{
ret = libusb_interrupt_transfer(
(libusb_device_handle *)m_devhandle,
m_outEP,
p,
size,
&actual_size,
1000
);
}
else
{
ret = libusb_control_transfer(
(libusb_device_handle *)m_devhandle,
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
m_set_report,
(2 << 8) | p[0],
0,
p,
size,
1000
);
}

if (ret < 0)
{
Expand Down
4 changes: 3 additions & 1 deletion libuuu/trans.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ class USBTrans : public TransBase
class HIDTrans : public USBTrans
{
int m_set_report;
int m_outEP;
public:
int m_read_timeout;
HIDTrans() { m_set_report = 9; m_read_timeout = 1000; }
HIDTrans() { m_set_report = 9; m_read_timeout = 1000; m_outEP = 0; }
void set_hid_out_ep(int ep) { m_outEP = ep; }
~HIDTrans() { if (m_devhandle) close(); m_devhandle = NULL; }
int write(void *buff, size_t size);
int read(void *buff, size_t size, size_t *return_size);
Expand Down

0 comments on commit d2fca8f

Please sign in to comment.