2020年1月25日 星期六

etrade 重新填寫 w-8ben

20200125 是農曆 20200101, 一樣發篇文章慶祝。

20230814 更新 w-8ben, 這次很小心注意 w-8ben 過期時間, 特地發問: [請益] 請問 etrade w8ben 更新時間

https://us.etrade.com/etx/hw/w8ben
我在這邊查詢自己的 w8ben 認證時間,
Certification completed on 01/17/2020

這是不是表示我在 01/17/2023  之前要更新 w8ben,
不過一直沒收到要更新的 email。

而且要更新的帳號也不能選, 所以無法線上更新。

--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.200.132.176 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Foreign_Inv/M.1672664805.A.2B9.html
→ pttccbbs: 應該是2023年底才到期吧 01/02 21:09
→ alex1973: Generally, a Form W-8BEN-E will remain valid for pu 01/02 21:11
→ alex1973: rposes of both chapters 3 and 4 for a period starti 01/02 21:11
→ alex1973: ng on the date the form is signed and ending on the 01/02 21:11
→ alex1973:  last day of the third succeeding calendar year 01/02 21:11
→ alex1973: 所以樓上的就是正確解,正常來說,今年九月左右券商就 01/02 21:15
→ alex1973: 會通知要更新,年底前更新完成就好了 01/02 21:15
→ descent: 太好了,感謝二位的解說。 01/02 21:26
推 jerrychuang: 原來是這樣,難怪我2020年初簽的也一直沒收到更新通 01/03 11:55
→ jerrychuang: 知 01/03 11:55
推 SWQLovE: 我今年八月就收到要更新w-8  到12月他一直寄我才看到要 01/03 16:14
→ SWQLovE: 更新 差一點就過期了 01/03 16:14
推 jerrychuang: 請問樓上上次是什麼時間簽的? 01/03 21:57
推 SWQLovE: 三年前還四年前的樣子 有點忘了 01/03 22:26
推 jerrychuang: 那合理阿,簽完後的第四年底才要再簽一次

更新流程比重填簡單很多, 一個頁面, 幾個問題, 拜 chatgpt 翻譯, 大概可以知道問題, 也可以知道整個流程的意思。


20191231 之前忘記填寫 w-8ben 重新認證的文件, 所以要整個重新填寫 w-8ben, 有點麻煩, 最好還是記得按時更新 (每 3 年需要更新一次)。

重新認證可以參考: 滿3年,W-8BEN重新確認

etrade 發了一封 "Immediate action required for uncertified tax status" 說明如何重新認證。
We are writing to inform you that your foreign tax status is uncertified. According to our records, your account referenced above has an expired Form W-8BEN. The documentation we requested to verify your tax status was not received by the December 31, 2019, deadline. As a result, your account is now subject to US backup tax withholding of up to 30%.

ACTION REQUIRED: To verify your tax status and help avoid further tax withholding, you must recertify your Form W-8BEN by following the steps below.

Step 1. Recertify your Form W-8BEN online:
  • Log on to your above-referenced account at etrade.com.
  • Click the green Start button and follow the step-by-step instructions.
  • Provide your legal name, date of birth, and foreign tax identification number (FTIN) and verify your address.
  • If you need to update your address, exit the recertification process, then click the profile icon in the upper-right corner of the page, choose My Profile, and enter your correct address.
  • If you are a US citizen or resident alien, please instead submit a completed Form W-9 available at etrade.com/taxforms, a copy of your Social Security card, and a signed and dated letter explaining the change from foreign to domestic tax status, following the instructions in Step 2 below.
If you are unable to recertify online:
  • Submit an original, signed Form W-8BEN with your FTIN. You can download and print Form W-8BEN at etrade.com/taxforms.
  • Follow the instructions in Step 2 to submit the documents.
Step 2. If applicable, submit the required documentation to E*TRADE. The documents can be securely uploaded at documentupload.etrade.com or mailed to: E*TRADE Securities PO Box 484 Jersey City, NJ 07303-0484 Additional important notes:
  • To avoid the 30% backup tax withholding, each account holder of a joint account must provide the requested certification and documentation.
  • If your government ID or passport was issued more than three years ago or the citizenship on your government ID or passport does not match the country of permanent residence address or mailing address on your account, please provide a utility bill or bank statement dated within the past six months that clearly shows your permanent residential address.
  • If you have already submitted your recertification documentation, please disregard this notice.
For questions about the certification process or US backup tax withholding, contact your tax advisor or visit the Internal Revenue Service (IRS) website at irs.gov. Instructions for Form W-8BEN can be found in IRS Publication 515 ("Withholding of Tax on Nonresident Aliens and Foreign Entities"). Once US backup tax is withheld, you may need to work with the IRS to obtain a refund. If you have questions, visit etrade.com/contact to access the toll-free number for your country, or call us at +1 650 599 0125, 24 hours a day, weekdays. You can also log on to your account and chat with us. (c) 2020 E*TRADE Securities LLC, Member FINRA/SIPC. All rights reserved. Important disclosures.

Step 1. Recertify your Form W-8BEN online, 這個是更新用的, 也就是需要在 20191231 之前填寫, 我的情形需要使用 Step 2. 的方法。

到這裡下載 pdf 文件。 https://us.etrade.com/forms-applications#taxAndLegal

W-8BEN Certificate of Foreign StatusEstablish that you are a non-U.S. person for federal income tax purposesDownload PDF


下載 W-8BEN Certificate of Foreign Status pdf

第一頁會需要填 etrade 帳號號碼, 在登入之後, 看到自己的帳號, 應該會在 Complete View, 點 Individual Brokerage …XXXX Show number 的 Show number 就可以到看到。

先在 pdf 上填寫資料, 參考「如何填寫Form W8BEN」, Foreign Tax Identification Number 需要填身份字號。

填寫完畢後列印出來, 簽名, 寫上填寫日期, 再把這張紙掃描起來上傳到 documentupload.etrade.com (需要登入 etrade)。

簽名是一個比較麻煩的地方, 簽名要和開戶時的一樣, 我忘記我是簽中文還是英文, 英文是姓氏在前面, 還是姓氏在後面, 很可能需要來回幾次才會和開戶時寫的簽名是一樣的。

另外還需要上傳護照資料, 如果護照有效日期期限超過 3 年, 會需要 utility bill or bank statement dated within the past six months (我不知道這是什麼?)。

我一開始忘記填寫居住地址, 會收到沒過的訊息。

It appears that the W-8BEN you have submitted to us was not filled out completely, due to line 3 being blank.


後來又重新填寫一張, 並且上傳。

從以下選單可以看到 w-8ben 認證。

CUSTOMER SERVICE << UPDATE YOUR ACCOUNT << VISIT MY PROFILE << ACCOUNT PREFERENCES << TAX PREFERENCES << ACCOUNT TAX STATUS

fig 1. 目前的 w-8ben 認證狀態


ref:

2020年1月24日 星期五

使用 jtag debug rpi2

今天 (20200124) 是 2019 農曆 12/31, 也就是除夕, 照慣例發篇文章慶祝。

How To JTAG Raspberry Pi 2
提供了一支程式, 在 linux 下設定 gpio 為 jtag。

Preparing Raspberry PI for JTAG Debugging

jtag 需要 table 1 的接腳以及 v3.3 和 ground, v3.3 和 RTCK 可以不用接。

table 1. jtag 接腳
JTAG pin"ALT4" mode (011)"ALT5" mode (010)
TDIGPIO26GPIO4
TDOGPIO24GPIO5
TMSGPIO27GPIO12
TCKGPIO25GPIO13
RTCKGPIO23GPIO6
TRSTGPIO22N/A

我選用了 table 1 紅色部份的 gpio。

JTAG RPi2 GPIO gpio number
VREF* Pin 1 3.3 v
nTRST Pin 15 gpio 22
GND Pin 9 GND
TDI Pin 7 gpio 4
TMS Pin 13 gpio 27
TCK Pin 22 gpio 25
TDO Pin 18 gpio 24

figure 1. 樹莓派 2 gpio pin
配合 figure 1, 就知道要怎麼把 jtag pin 接起來。

再來是設定 gpio, 把 gpio 設定成 jtag。



從這幾頁可以得知:

000 = GPIO Pin 9 is an input
001 = GPIO Pin 9 is an output
100 = GPIO Pin 9 takes alternate function 0
101 = GPIO Pin 9 takes alternate function 1
110 = GPIO Pin 9 takes alternate function 2
111 = GPIO Pin 9 takes alternate function 3
011 = GPIO Pin 9 takes alternate function 4
010 = GPIO Pin 9 takes alternate function 5

所以把相對應的 gpio 設定為 011 或是 010 即可。

gpio4 要設定為 010
gpio2X 要設定為 011

gpio4 在 GPFSEL0 (實體位址: 0x3f200000)
所以把 GPFSEL0 bit 12:14 設定為 010 即可。

gpio2X 在 GPFSEL2 (實體位址: 0x3f200008), 一樣的道理。

figure 2. jtag 硬體接線, 右上 3 pin 是 uart。

以下提供 u-boot 的設定指令:
mw.l 0x3f200008 0x61b6c0
mw.l 0x3f200000 0x2000

c 程式
void enable_jtag_pin()
{
  volatile u32 gpfsel0 = 0x3f200000;
  volatile u32 gpfsel2 = 0x3f200008;

  *(volatile u32*)gpfsel0 = 0x2000;
  *(volatile u32*)gpfsel2 = 0x61b6c0;

}
若成功的話, jtag 軟體可以看到以下畫面。

2020年1月17日 星期五

c++ vector 呼叫容器元素的解構函式

constructor 我喜歡翻譯成建構函式, 因為它本質的確是一個函式; destructor 我喜歡的翻譯是解構函式。當我寫 c 的時候, init() 我會取名 ctor(); destory() 我會取名為 dtor()。

在使用 std::vector 的時候, 會因為 vector 的容量變化而呼叫元素的解構函式, 這個負擔大不大呢?

vector 提供的 reserve 有沒有幫助?

我之前沒有細想這個問題。

v.push_back.cpp
 1 #include <vector>
 2 #include <stdio.h>
 3 #include <iostream>
 4 
 5 using namespace std;
 6 
 7 class MyClass
 8 {
 9   public:
10     MyClass()
11     {
12       index_ = num_;
13       ++num_;
14       printf("ctor index_: %d, num_: %d\n", index_, num_);
15     }
16     MyClass(const MyClass &&rhs)
17     {
18       index_ = rhs.index_;
19       printf("move ctor index_: %d, num_: %d\n", index_, num_);
20     }
21     MyClass(const MyClass &rhs)
22     {
23       index_ = rhs.index_;
24       ++num_;
25       printf("copy ctor index_: %d,num_: %d\n", index_, num_);
26     }
27     ~MyClass()
28     {
29       --num_;
30       printf("dtor, index_: %d, num_: %d\n", index_, num_);
31     }
32     static int num_;
33     int index() const {return index_;}
34   private:
35     int  index_;
36 };
37 
38 int MyClass::num_=0;
39 
40 int main(int argc, char *argv[])
41 {
42   {
43     vector<MyClass> my_class;
44     //my_class.reserve(100);
45     cout << "capacity(): " << my_class.capacity() << endl;
46     MyClass c1,c2;
47     cout << "push c1" << endl;
48     my_class.push_back(c1);
49 
50     cout << "my_class[0].index(): " << my_class[0].index() << endl;
51 
52     cout << "c1 capacity(): " << my_class.capacity() << endl;
53 
54     cout << "push c2" << endl;
55     my_class.push_back(c2);
56 
57     cout << "my_class[1].index(): " << my_class[1].index() << endl;
58 
67   }
68   printf("end\n");
69   return 0;
70 }

由於我沒有執行 reserve, capacity() 一開始是 0, push c1 之後, vector 先配置 1 個元素的記憶體空間, copy ctor 發動, 複製 c1 到 vector[0], 目前總共有 c1, c2, vector[0] 總共 3 個 MyClass, capacity() 為 1。

push c2 之後, capacity() 空間不夠, 先配置 2 個元素的記憶體空間, 呼叫 copy ctor 複製 c2 以及在原本的 vector[0], 這時候共有 5 個 MyClass。

再來發動「原本的 vector[0]」 dtor, 現在的 MyClass 變為 4 個, 原本的有 1 個元素的記憶體空間被歸還。

在 vector 解構後, 會執行 4 次 MyClass dtor。

result 1. 總開銷
ctor: 2
copy ctor: 3
dtor: 5

嚴格來說最開始的 ctor:2, 和最後的 dtor:2 不能算在 vector 頭上, 重新計算之後。

result 2. 總開銷
ctor: 0
copy ctor: 3
dtor: 3

以 result 1 來看, 老實說我有點驚訝這個頻繁的次數, 以 result 2 結果來看就還好。

但如果用 v-1.push_back.cpp 的寫法, 因為 push_back 無法寫 my_class.push_back(); 得寫成 my_class.push_back(MyClass{});, 這寫法所有的開銷就得算在 vector 頭上了。

總開銷:
ctor: 2
copy ctor: 3
dtor: 5

和 result 1 一樣。

v-1.push_back.cpp
 1 #include <vector>
 2 #include <stdio.h>
 3 #include <iostream>
 4 
 5 using namespace std;
 6 
 7 class MyClass
 8 {
 9   public:
10     MyClass()
11     {
12       index_ = num_;
13       ++num_;
14       printf("ctor index_: %d, num_: %d\n", index_, num_);
15     }
23     MyClass(const MyClass &rhs)
24     {
25       index_ = rhs.index_;
26       ++num_;
27       printf("copy ctor index_: %d, num_: %d\n", index_, num_);
28     }
29     ~MyClass()
30     {
31       --num_;
32       printf("dtor, index_: %d, num_: %d\n", index_, num_);
33     }
34     static int num_;
35     int index() const {return index_;}
36     int  index_;
37   private:
38 };
39 
40 int MyClass::num_=0;
41 
42 int main(int argc, char *argv[])
43 {
44   {
45     vector<MyClass> my_class;
46     //my_class.reserve(100);
47     cout << "capacity(): " << my_class.capacity() << endl;
48     //MyClass c1,c2,c3;
49     cout << "push c1" << endl;
50     my_class.push_back(MyClass{});
51 
52     cout << "my_class[0].index(): " << my_class[0].index() << endl;
53 
54     my_class[0].index_ = 99;
55 
56     cout << "xx my_class[0].index(): " << my_class[0].index() << endl;
57 
58     cout << "c1 capacity(): " << my_class.capacity() << endl;
59 
60     cout << "push c2" << endl;
61     my_class.push_back(MyClass{});
62 
63     cout << "my_class[1].index(): " << my_class[1].index() << endl;
73   }
74   printf("end\n");
75   return 0;
76 }

list 3. v-1 執行結果
 1 capacity(): 0
 2 push c1
 3 ctor index_: 0, num_: 1
 4 copy ctor index_: 0, num_: 2
 5 dtor, index_: 0, num_: 1
 6 my_class[0].index(): 0
 7 xx my_class[0].index(): 99
 8 c1 capacity(): 1
 9 push c2
10 ctor index_: 1, num_: 2
11 copy ctor index_: 1, num_: 3
12 copy ctor index_: 99, num_: 4
13 dtor, index_: 99, num_: 3
14 dtor, index_: 1, num_: 2
15 my_class[1].index(): 1
16 dtor, index_: 99, num_: 1
17 dtor, index_: 1, num_: 0
18 end

list 1 push_back 執行結果
 1 capacity(): 0
 2 ctor index_: 0, num_: 1
 3 ctor index_: 1, num_: 2
 5 push c1
 6 copy ctor index_: 0,num_: 3
 7 my_class[0].index(): 0
 8 c1 capacity(): 1
 9 push c2
10 copy ctor index_: 1,num_: 4
11 copy ctor index_: 0,num_: 5
12 dtor, index_: 0, num_: 4
13 my_class[1].index(): 1
15 dtor, index_: 1, num_: 3
16 dtor, index_: 0, num_: 2
17 dtor, index_: 0, num_: 1
18 dtor, index_: 1, num_: 0
19 end

如果不想付出這麼頻繁的代價, 可以使用 vector<MyClass*> my_class; 指標的版本, 或是使用 reserve, reserve 可以減少發動 ctor, dtor 的次數。

c++11 之後有了 emplace_back(), 來看看這個新東西所帶來的效率改善。

直接寫 my_class.emplace_back() 就可在 vector[0] 插入一個 MyClass 物件。

push c1 時, 發動一次 ctor, push c2 時, c2 發動一次 ctor, 原本的 vector[0] 發動一次 copy ctor, 這時候總共有 3 個 MyClass, 之後 vector[0] 發動一次 dtor, 現在的 MyClass 總數為 2 個。

當 vector 解構之後, 發動 2 次 dtor。

總開銷:
ctor: 2
copy ctor : 1
dtor: 3

和 result 2. 的開銷一樣, 不過使用 emplace_back() 可是貨真價實的省下 2 個 ctor, 這使用了 variadic template 的技術, 我總算找到使用 variadic template 的原因了。

v.emplace_back.cpp
 1 #include <vector>
 2 #include <stdio.h>
 3 #include <iostream>
 4 
 5 using namespace std;
 6 
 7 class MyClass
 8 {
 9   public:
10     MyClass()
11     {
12       index_ = num_;
13       ++num_;
14       printf("ctor index_: %d, num_: %d\n", index_, num_);
15     }
16     MyClass(const MyClass &&rhs)
17     {
18       index_ = rhs.index_;
19       printf("move ctor index_: %d, num_: %d\n", index_, num_);
20     }
21     MyClass(const MyClass &rhs)
22     {
23       index_ = rhs.index_;
24       ++num_;
25       printf("copy ctor index_: %d,num_: %d\n", index_, num_);
26     }
27     ~MyClass()
28     {
29       --num_;
30       printf("dtor, index_: %d, num_: %d\n", index_, num_);
31     }
32     static int num_;
33     int index() const {return index_;}
34   private:
35     int  index_;
36 };
37 
38 int MyClass::num_=0;
39 
40 int main(int argc, char *argv[])
41 {
42   {
43     vector<MyClass> my_class;
45     cout << "capacity(): " << my_class.capacity() << endl;
48     cout << "push c1" << endl;
51     my_class.emplace_back();
52 
53     cout << "my_class[0].index(): " << my_class[0].index() << endl;
54 
55     cout << "c1 capacity(): " << my_class.capacity() << endl;
56 
57     cout << "push c2" << endl;
59     my_class.emplace_back();
60 
61     cout << "my_class[1].index(): " << my_class[1].index() << endl;
62 
71   }
72   printf("end\n");
73   return 0;
74 }

編譯: g++ -std=c++2a v.emplace_back.cpp -o v.emplace_back

list 2. emplace_back
 1 capacity(): 0
 2 push c1
 3 ctor index_: 0, num_: 1
 4 my_class[0].index(): 0
 5 c1 capacity(): 1
 6 push c2
 7 ctor index_: 1, num_: 2
 8 copy ctor index_: 0,num_: 3
 9 dtor, index_: 0, num_: 2
10 my_class[1].index(): 1
11 dtor, index_: 0, num_: 1
12 dtor, index_: 1, num_: 0
13 end

emplace_back:

2020年1月10日 星期五

雲端發票如何兌獎

這次電費發票中獎了, 但不知道要怎麼領, 找了一些資料後, 可以到「電力公司 - 發票查詢」查詢。

到這裡查詢雲端發票:
雲端發票專屬獎中獎號碼

查電力公司寄來的發票中了多少錢:
請輸入發票資訊

雲端發票最小獎是 500nt, 在 7-11 需要用 ibon 列印出單據來兌換, 會被扣 2 元的印花稅, 實拿 498。

ref:
雲端發票專屬獎宣導專區