One of the prevailing issues with the SODP build of AOSP was that every time I hooked up my phone to the computer to transfer files, it would cause the phone to crash and reboot. Obviously that is not very productive. I was a bit stumped and decided to join the unofficial SODP telegram group and ask if the developers there had ever seen this issue.

Sure enough, they had. Not only that, but they pointed me to a bug-tacker tool that allowed me to search issues they’ve seen before! It was a huge help! In there, I found a post by a user who had similar problems with another SODP phone. More importantly, there was a helpful response from a developer who pointed out what the issue was, and how to fix it!

It appears that the problem is the buffer size for the file transfer. All one has to do to fix it was make a simple change to the buffer size in

drivers/usb/gadget/function/f_mtp.c

Once you make the edits, then MTP works. He put together a patch, if you don’t want to hand edit them. Here it is:

diff --git a/drivers/usb/gadget/function/f_mtp.c b/drivers/usb/gadget/function/f_mtp.c
index 7692b9d86633..ddf5faedc3c6 100644
--- a/drivers/usb/gadget/function/f_mtp.c
+++ b/drivers/usb/gadget/function/f_mtp.c
@@ -42,8 +42,8 @@
 
 #include "../configfs.h"
 
-#define MTP_RX_BUFFER_INIT_SIZE    1048576
-#define MTP_TX_BUFFER_INIT_SIZE    1048576
+#define MTP_RX_BUFFER_INIT_SIZE    16384
+#define MTP_TX_BUFFER_INIT_SIZE    16384
 #define MTP_BULK_BUFFER_SIZE       16384
 #define INTR_BUFFER_SIZE           28
 #define MAX_INST_NAME_LEN          40

It’s great to have that working properly now! It’s also great to work with a team of really helpful developers, for a change.

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *